#Private members not accessible
35 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question run !howto ask.
Do make em friend ie:
Add at your class body in the bottom:
friend ifstream & operator>>(..;
friend ofstream & operator<<(..;
I omitted the full declaration
I see now you have actually done this - so I'm looking
How about you add :: before in the friend declarations
like friend ifstream & ::operator>>
This doesn't work either
In the operator >>, the complex parameter shouldn't be const, it's modified.
And in the header, you declared the operator << with the wrong return type complex => ostream &.
ok
Can I upload the files over here so that if anyone online can fix it?
Thanks
@vernal ridge Has your question been resolved? If so, run !solved :)
No
My brain has got fried... got stuck in it for hours and did some few tries. Then got busy with something else
Will you be able to solve it please?
really appreciate your help
it might work
ok lemme try now
it worked for me
Coz will be heading out soon
ok
friend istream & operator>>(istream &is, complex &b) {
is >> b.real;
is >> b.imaginary;
return is;
}
friend ostream & operator<<(ostream &os, const complex &b) {
os << b.real<<"\n";
os << b.imaginary<<"\n";
return os;
}
looks good now
Having issues with overloading ~ operator
which is supposed to return the complex conjugate
try this out
should work
This question thread is being automatically closed. If your question is not answered feel free to bump the post or re-ask. Take a look at !howto ask for tips on improving your question.