I would like to overwrite the "<<" operator three times. Bottle 2 should give bottle 1 some water.
For example:
Bottle bottle1(200);
Bottle bottle2(200);
bottle1 << 200 << bottle2;
Any ideas?
I tried following in my header file:
friend void operator << (Bottle &a, const int &waterinml);
friend void operator << (const int &waterinml, Bottle &b);
And following in my class source file:
void operator<< (Bottle &a, const int &waterinml)
{
a.addWater(waterinml);
}
void operator<< (const int &waterinml, Bottle &b)
{
b.removeWater(waterinml);
}
But that does not work. Overloading once works. For example:
bottle << 200;
would work, but not the example above.
Thank you for your help in advance.