Okay. I have searched both my textbook and the internet for the past few hours, and I've made progress in various ways - but I'm still having a problem with my code to overload the ostream operator (<<).
I'm trying to include all relevent information, please ask if there's anything I left out. Most likely it's going to be one of those really, really stupid, simple things... so any and all help appreciated. This is part of a uni assignment, which is 95% done, except for this one function...
I have a class called set, with various functions declared and working. I'm now trying to use the ostream overloader to output the contents of a set.
Here is the declaration in the header file:
|
friend ostream operator<<(ostream &os, const set mySet);
|
Private data for class set:
1 2 3
|
private:
vector <bool> setlist; // indicates set elements as true
int cardinality; // number of (true) items in set
|
And here is the code I have in set.cpp:
1 2 3 4 5
|
ostream operator<<(ostream &os, const set mySet)
{
mySet.display();
return os;
}
|
It is on line 4 of the code in set.cpp that I'm encountering problems. There's a squiggly red line underneath it, it won't compile, and the error message is "within this context".
Thanks in advance :)