#include <iostream>
#include <typeinfo>
using namespace std;

class base
{
public: 
    template<typename T>
    void BindType( ) // do something with the type
    { cout << typeid(T*).name()<<endl; }
    virtual ~base() {};
};

class derived : public base
{
public: 
    void foo() { BindType<decltype(this)>( ); } 
};

class derived_once_more : public derived
{
};

int main() {
	derived_once_more dom;
	derived dd; 
	dom.foo(); 
	dd.foo(); 
	return 0;
}