Image

Imagedeana_in_texas wrote in Imagecpp

Microsoft Visual C++ 6.0 Professional

I know this is an old version and I should be using .NET, but I'm doing this for someone else and don't have that option.

I need to overload operator<< and operator>>

The way in which I learned to do it is not working.

Originally I learned in the header file to make these functions as friend functions to the class, ie.

class C
{
friend std::ostream & operator<<( std::ostream &, const C & );

/* rest of class */
};


Compiler error says I can not make it a friend, so I took it out.

Now it tells me that "binary operator<< has too many parameters" It does? Where? I see two.

I'm very confused. So if anyone knows how to do this in MSVC++ 6.0, I'd really appreciate it...

Edit: Ok, I got it. Apparently they -do- need to be friends, but for whatever reason I have to define them inline in the header file. Tried a random thing, and it worked. Great :)