• Welcome to Valhalla Legends Archive.
 

[C++]Operator overloading

Started by shout, December 10, 2005, 04:17 PM

Previous topic - Next topic

shout

In a recent post by MyndFyre, he told someone to overload the << and >> to make a buffer look cool. I did this, but now I have a problem.

If I do something like:

*buff << dwval;

it works. But:

*buff << dwval1 << dwval2;

gives me a

error C2296: '<<' : illegal, left operand has type 'Buffer *' bufftest.cpp 130


This is my first venture into C++ operator overloading :/

Kp

You're probably returning the wrong type in your operator<<.  You should return *this.
[19:20:23] (BotNet) <[vL]Kp> Any idiot can make a bot with CSB, and many do!

shout

Yes, that worked. I was returning a pointer to the class. I see my error now.

MyndFyre

Quote from: Shout on December 10, 2005, 04:17 PM
In a recent post by MyndFyre, he told someone to overload the << and >> to make a buffer look cool. I did this, but now I have a problem.
Thanks for trying to blame me!  :P
QuoteEvery generation of humans believed it had all the answers it needed, except for a few mysteries they assumed would be solved at any moment. And they all believed their ancestors were simplistic and deluded. What are the odds that you are the first generation of humans who will understand reality?

After 3 years, it's on the horizon.  The new JinxBot, and BN#, the managed Battle.net Client library.

Quote from: chyea on January 16, 2009, 05:05 PM
You've just located global warming.

shout

Quote from: MyndFyre on December 10, 2005, 07:48 PM
Quote from: Shout on December 10, 2005, 04:17 PM
In a recent post by MyndFyre, he told someone to overload the << and >> to make a buffer look cool. I did this, but now I have a problem.
Thanks for trying to blame me! :P
Welcome :)