#ifndef CLASS_TEMPLATE_1 #define CLASS_TEMPLATE_1 #include "NormalOldClass.h" #include "ClassTemplate2.h" #include "ClassTemplate3.h" #include template class ClassTemplate1 { friend void f1(); friend void f2(ClassTemplate1& TheObject); friend void NormalOldClass::f4(); friend void ClassTemplate2::f5(ClassTemplate1& TheObject); friend class NormalOldClass2; friend class ClassTemplate3; public: private: T m_Data; int m_Int; }; //f1 is a friend to ever class instantiated from the ClassTemplate1 //only one version of this funciton exists void f1() { cout << "Its Great to be a friend" << endl; ClassTemplate1 i; i.m_Data = 7; i.m_Int = 14; ClassTemplate1 f; f.m_Data = 7; f.m_Int = 14; } //f2 is a friend for a particular type T such as an int or float. //A new copy of this function is created for every type of T used. template void f2(ClassTemplate1& TheObject) { cout << "I am your friend if you are a T like me" << endl; TheObject.m_Data = 7; TheObject.m_Int = 14; } #endif