я написал следующую тестовую программу:Перегрузки оператор =
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;
}
Я перегруженный = следующим образом:
void Complex::operator=(const Complex &a)//mulptiplication
{
real=a.real;
imag=a.imag;
}
Но я получаю ошибки, как: не подходят для ooperator < <. Может ли кто-нибудь помочь с ошибкой?
Пожалуйста, добавьте ошибку компилятора. –