STL:类模板

来源:互联网 发布:win10怎么优化内存 编辑:程序博客网 时间:2024/04/27 23:27
// hello.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"template<typename T>class Motor{public:Motor(){}~Motor(){}public:void Run();void Proc();void Proc2(){int cc =3;      }};template<typename T>void Motor<T>::Run(){((T *) this)->Proc();((T *) this)->Proc2();}class MotorBike:public Motor<MotorBike>{public:MotorBike(){}~MotorBike(){}public:void Proc(){int c = 2;}void Proc2(){int cc =3;     }};int _tmain(int argc, _TCHAR* argv[]){MotorBike objMotor;objMotor.Run(); //MotorBike::Proc >>MotorBike::Proc2();return 0;}


 

0 0