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