I have been looking through a lot of different examples and explanations, but none has really answered what I am looking for. I have three classes with a method called connect for each one:
class foo { ... }
void foo::connect(bar br) { ... }
class bar { ... }
bar& bar::connect(baz bz) { ... }
class baz { ... }
baz& baz::connect() { ... }
In my main class, I 'connect' them like this:
foo.connect(bar);
bar.connect(baz);
baz.connect();
or:
foo.connect( bar.connect( baz.connect() ) );
(I know this is briefly explained, I can explain it better if needed)
So, I was trying to overload the operator '>>' to have something like this in the main function:
foo >> bar >> baz;
For the first operator it works, so if I simply do the following, it works fine:
foo >> bar.connect(baz.connect);
But, when I set the other '>>' operator g++ returns this error:
error: no match for ‘operator>>’ in ‘operator>>((* & foo), (* & bar)) >> baz.baz::connect()’
I think I'm not overloading the operator '>>' properly:
bar& operator>> (bar &br, baz &bz)
{
...
}
Thanks for the help :)