64,282
社区成员
发帖
与我相关
我的任务
分享
template<typename _TP>
class C
{
public:
typedef _TP PAR;
PAR* p;
C(_TP* p_) :p(p_){};
void f()const{return p->f();};
};
template<typename _TP>
class B : public C<B<_TP> >
{
public:
typedef _TP PAR;
PAR* p;
B(_TP* p_) :C(this), p(p_){};
void f()const{return p->f();} ;
};
class A: public B<A>
{
public:
A() :B(this){}; // warning C4355: “this”: 用于基成员初始值设定项列表
void f()const{cout << "the end!" <<endl;} ;
};
void f(const C<B<A> >& c) //
{
c.f();
}
int _tmain(int argc, _TCHAR* argv[])
{
A a;
f(a);
printf("The End\n");
::getchar();
return 1;
}