class B { public: int b; }; template <class T> class C; class A { int a; public: A(const B &b) : a(b.b) {} template <class T> A &operator << (const C<T> &); }; template <class T> class C { public: T c; C(const T &n) : c(n) {} }; template <class T> inline A &A::operator << (const C<T> &c) { a = (int)c.c; return *this; } template <class T> inline A &operator << (B &b, const C<T> &c) { return A(b) << c; } int main() { B b; b << C<double>(1.2); return 0; }