Operators aren't anything magical: they are just functions spelled in a funny way. That is, your statement
foo >> bar >> baz;
actually just calls [or tries to call]
operator>> (operator>> (foo, bar), baz);
That is, you need the operators
bar& operator>> (foo& f, bar& b) {
f.connect(b);
return b;
}
bar& operator>> (bar& b0, baz& b1) {
return b0.connect(b1);
}
Note, that the last connect()
you have won't be doable using operator>>()
because the operator always takes two arguments.