Printing derived class name in base class
<p>How can I print out the derived class name from the base class without chaining constructors all the way down. In other words is it possible to do this strictly from the base class without adding code in each derived class?</p>

<p>This is an example of what I got, and if there's a way I'd like to get rid of the constructor chaining.</p>

<p><strong>EDIT:</strong>
Ideally I am looking for something to add into the base class without having to edit all derived classes. At the moment my real code has got ~17 classes(with need for more), so something that could do the job straight from the base class would be ideal. Even if it's compiler specific (g++ or clang).</p>

<pre><code>#include &lt;iostream&gt;

class Base {
public:
    Base(std::string id) {
            std::cout&lt;&lt;"Creating "&lt;&lt;id&lt;&lt;std::endl;
    }
};

class Child : Base {
public:
    Child(std::string id) : Base(id) {}
    Child() : Base(typeid(this).name()) {}
};

class GrandChild : Child {
public:
    GrandChild(std::string id) : Child(id) {}
    GrandChild() : Child(typeid(this).name()) {}
};

class GrandGrandChild : GrandChild {
public:
    GrandGrandChild(std::string id) : GrandChild(id) {}
    GrandGrandChild() : GrandChild(typeid(this).name()) {}
};



int main() {
    GrandGrandChild *A = new GrandGrandChild();
    GrandChild *B = new GrandChild();
    Child *C = new Child();

    return 0;
}
</code></pre>

<p>Which prints:</p>

<pre><code>Creating GrandGrandChild
Creating GrandChild
Creating Child
</code></pre>

<p>But with compiled added prefix.</p>
