Learn ft=rom WTL: CXXImpl<T>
// t9.cpp : Defines the entry point for the console application. // #include "stdafx.h" class CRecordBase{ public: virtual ~CRecordBase()=0{} virtual CRecordBase* scale(float scale)=0; }; template <class T> class CRecordBaseT: public CRecordBase{ public: virtual CRecordBase* scale(float scale){ T* ret(new T); ((T*)this)->scaleTo(scale, ret); return ret; } }; class BRecord:public CRecordBaseT<BRecord>{ public: int scaleTo(float scale, BRecord* res){ return 0; } }; // CRecordBase <-- CRecordBaseT<> <-- BRecord void main(){ BRecord r; r.scale(1); }