I have a class in which I m trying to overload the << operator. For some reason, it is not being overloaded.
Here is my .h file:
friend std::ostream& operator<<(std::ostream&, const course &); //course is my class object name
in my .cpp, I have this as my implementation:
std::ostream& operator<<(std::ostream &out, const course & rhs){
out << rhs.info;
return out;
}
This should be correct, but when I try to compile it, it says that cout << tmp; is not defined in ostream.
I ve included iostream in my .cpp and .h
I m been pulling my hair out trying to figure this out. Can you see anything that s wrong with this?
EDIT: Since what I m doing seems to be correct, here s all of my source code: http://pastebin.com/f5b523770
line 46 is my prototype
line 377 is the implementation
line 435 is where it fails when i attempt to compile it.
also, I just tried compiling it on another machine, and it gives this error instead:
course.cpp:246: error: non-member function std::ostream& operator<<(std::ostream&, const course&) cannot have cv-qualifier
make: *** [course.o] Error 1