Hi!
I want to overload << operator so that it can print an arry defined in
MyClass.My problem is that I want to print only a no of elements NOT
all the elements in the array and this no of elements depends upon
user input.The code below describes this in detail:
class MyClass
{
public:
unsigned short x;
unsigned short y;
unsigned short num_elems;
unsigned short *elem_array;
// Constructor
// Destructor
// Print out array info
friend ostream& operator << ( ostream &output, const MyClass &m
);
};
After the user has given the values x=5,y=10 and no of elements = 2 I
have 2 elements in the array.( no of elements can be more depends on
user)
ostream& operator << ( ostream &output, const MyClass &m )
{
output << "------------------------BEGIN -------------------------" <<
endl
<< endl
<< "X: " << m.x << endl
<< "Y: " << m.y << endl
<< "Num of Elements : "<<m.num_elems<< endl
<<"Elements : "
<<<<<<<<<<<<<<????How can I print Array>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<< "------------------------- END
--------------------------" << endl;
return output;
}