Mon May 04, 2009 12:20 am
#include <iostream>
using std::cout;
using std::endl;
using std::ios;
#include<new>
#include<iomanip>
//using std::fix;
using std::setprecision;
template < typename T >
class Array{
public:
Array(int=5);
~Array() {delete[] arrayPtr; }
T arrayRef(int)const;
int getsize() const;
private:
int size;
T *arrayPtr;
};
template< typename T>
Array< T >::Array(int x)
{
size=x;
arrayPtr[i] = 1.0 * i;
}
template<typename T>
T Array< T >::arrayRef(int num)const
{
return arrayPtr[num];
}
template< typename T >
int Array<T>::getSize() const
{
return getSize;
}
template <typename T >
void printArray(const Array<T> &a)
{
for (int i=0; i< a.getSize(); i++)
cout << a.arrayRef(i) << " ";
cout << endl << endl;
}
int main()
{
int fixed;
Array< int > intArray(4);
Array< double > doubleArray;
cout << setprecision(2);
printArray( intArray );
printArray( doubleArray);
return 0;
}
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.