c++怎样在一个模板方法里面获得调用此方法的对象?

c++怎样在一个模板方法里面获得调用此方法的对象?用this并不行啊。求大神解答

这个没有什么好的办法,可以在代码里直接判断而不是模板

你要什么目标?


struct DABase{  virtual void foo(){};};
struct DA   :public DABase{ };

template<class TP_>
void foo(TP_& r)
{
    printf(typeid(r).name());
}

int _tmain(int argc, _TCHAR* argv[])
{
    DABase b;
    DA d;
    foo(b);
    foo(d);


    getchar();
    return 0;

}