it must return an ostream reference (ostream&) not void
To do something like this:
out_stream<<array1<<array2<<array3;
I have run the program it is right. i have done it by friend function. my code is as below let's try it......
#include<iostream>
using namespace std;
class Array
{
public:
int array[8];
friend void operator <<(ostream &, Array );
};
void operator <<(ostream& out,Array array1)
{
for(int i=0;i<8;i++)
{
out<<"\t"<<array1.array[i];
}
}
int main()
{
Array a;
cout<<"\n\t Enter 8 integers for array:";
for(int i=0; i<8; i++)
{
cin>>a.array[i];
}
cout<<"\n\t the elements of array are:";
cout<<a;
cout<<endl;
return 0;
}