#ifndef CLASS_TEMPLATE_2 #define CLASS_TEMPLATE_2 template class ClassTemplate1; template class ClassTemplate2 { public: T m_Data2; void f5(ClassTemplate1& TheObject); private: }; //this is a friend function of ClassTemplate1 where //it's T is the same T as this T, //A new copy of this function will be created for every type T template void ClassTemplate2::f5(ClassTemplate1& TheObject) { cout << "Its Great to be a friend funcion of a different class template" << endl; TheObject.m_Data = 7; TheObject.m_Int = 14; } #endif