class Buddy {}; template<class T> class My { public: void play( My<Buddy>& s ) { s.i=3; } private: int i; template<class> friend class My; }; int main() { My<int> h; My<Buddy> me; My<Buddy> bud; h.play(bud); me.play(bud); return 0; }