How do i implement the class smartArray, as a class templateelemtype to accept any numerical value.
How do i implement the class smartArray, as a class templateelemtype to accept any numerical value. Below is code i have issues , in being unable to make theostream and istream work for the template template
class smartArray{
friend ostream& operator
friend istream& operator>>(istream &, elemType &); // issues with making this work as template
public:
elemType *elements; // dynamic array, memory is allocated inthe
// constructor. Use *this to access size member.
int length(); // returns the length of the array
smartArray(); // default constructor, sets size to 0
smartArray(int size); // constructor, allocates the memory for*elements, if size==0, then no memory allocation is done
~smartArray() ;// destructor
void resize(int newsize) ;
private:
int size;
}; template
ostream& operator
out
for (int i = 0 ; i
out
}
out
return out;
} template
istream& operator>>(istream &in, elemType& b){
for (int i = 0 ; i
{ cout << “Enter element number “<< i << “: “; in>> b.elements[i];}
return in;
} . . .