Reputation: 37
Why I got an error with this code :
ostream operator<<(ostream flux, Perso const A)
{
A.O_Show(flux);
return flux;
}
error: use of deleted function 'std::basic_ostream<char>::basic_ostream(const std::basic_ostream<char>&)'|
And no errors with :
ostream& operator<<(ostream& flux, Perso& const A)
{
A.O_Show(flux);
return flux;
}
Can you explain what's the difference?
Upvotes: 2
Views: 91
Reputation: 1
As for your code
ostream operator<<(ostream flux, Perso const A) {
A.O_Show(flux);
return flux;
}
You cannot copy a std::ostream
as return value (prior to c++11 standards, and even these are protected
in 1st place), just change your code to
ostream& operator<<(ostream& flux, Perso& const A) {
// ^
A.O_Show(flux);
return flux;
}
Upvotes: 2