vendredi 28 mars 2014

Overloading = operator


Vote count:

0




I wrote the following test program:



int main(int argc, char** argv)
{

ifstream inFile;
inFile.open("D:\\C++\\Assignments\\in1.txt");
if (!inFile) {
cout << "Unable to open file";
exit(1); // terminate with error
}
Complex a,b,c;
inFile >> a;
inFile >> b;
ofstream out;
out.open("D:\\C++\\Assignments\\out1.txt");
out << a <<endl<< b<<endl; // dumps data to a stream connected to a file
out << c=a <<endl;
out.close();



return 0;
}


I have overloaded = as following:



void Complex::operator=(const Complex &a)//mulptiplication
{
real=a.real;
imag=a.imag;
}


But I am getting errors like: no match for ooperator <<. Can anyone help with the error?



asked 2 mins ago






Aucun commentaire:

Enregistrer un commentaire