In the HPP file:
#include <stdio.h> #include <string.h> class ParentFirst { public: ParentFirst() { } ParentFirst(const char * pName, const int pAge) { strcpy(this->name, pName); this->age = pAge; } ~ParentFirst() {} virtual void Show() { printf("print in parent First \n"); } private: ParentFirst(const ParentFirst& disabled_Arg); ParentFirst& operator=( const ParentFirst& rhs ); char name[20]; int age; }; template<typename T1, typename T2> class MyClass : public ParentFirst { public: MyClass(T1 t1, T2 t2); void Show(); private: T1 t1; T2 t2; };
In the CPP file
#include <stdio.h> #include "templ.hpp" struct TestStruct { int i; }; template<typename T> double Add(T x, int y) { return x + y; } template<typename T1, typename T2> MyClass<T1, T2> :: MyClass(T1 t1_Arg, T2 t2_Arg) : ParentFirst() { t1 = t1_Arg; t2 = t2_Arg; } template<typename T1, typename T2> void MyClass<T1, T2> :: Show() { printf("MyClass show is comming %d \n", t1 + t2); ParentFirst::Show(); } int main() { // double r = Add(10, 5); //printf("result is %f\n", r); MyClass<int, int> my(10, 10); my.Show(); const int j = 939; const int * k; k = const_cast<int*>(&j); printf("*k is %d\n", *k); return 0; }