• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

C++ and Code Warrior Gurus: Need some help...

Zuerst

Member
I'm trying to overload the ostream operator << and the debugger gave me an error that I have no idea how to fix... any ideas? Thanks in advance.

ptr[] is a pointer to an array of doubles...

Here is my definition for <<... it is a friend function to the Set class

ostream& operator<< (ostream& out, const Set& a) {
for (Node* ptr = a.firstPtr->nextPtr; ptr != 0; ptr = ptr->nextPtr) {
for (int i = 0; i < a.setSize; i++) {
out << ptr;
out << " ";
}
out << endl;
}
out << endl;
return out;
}

And here is the error message...

Error : illegal operands 'std::basic_ostream<char, std::char_traits<char>>' << 'Node'
PA4.cpp line 72 out << ptr;
 
Back
Top