What is the actual meaning of keyword "this"?
<p>I have two questions related to C++:</p>

<p>In many textbooks, the keyword <code>this</code> is a pointer to the <strong>calling object</strong>.  Correct? </p>

<p>As i like to play with coding, i wrote the following simple code:</p>

<pre><code>struct Base
{
    void g();
    virtual void f();
};

void Base::f() {
    cout &lt;&lt; "Base::f()" &lt;&lt; endl;
}

void Base::g() {
    cout &lt;&lt; "Base::g()" &lt;&lt; endl;
    cout &lt;&lt; "sizeof(*this) : " &lt;&lt; sizeof(*this) &lt;&lt; endl;
    this-&gt;f();
}

struct Derived : public Base
{
    int d;
    void f();
};

void Derived::f()
{
    cout &lt;&lt; "Derived::f()" &lt;&lt; endl;
}

int main()
{
    Base a;
    Derived b;

    cout &lt;&lt; "sizeof(a) : " &lt;&lt; sizeof(a) &lt;&lt; endl;
    cout &lt;&lt; "sizeof(b) : " &lt;&lt; sizeof(b) &lt;&lt; endl;

    a.g();
    b.g();
}
</code></pre>

<p>The above code produces the following output:</p>

<pre><code>sizeof(a) : 4
sizeof(b) : 8
Base::g()
sizeof(*this) : 4
Base::f()
Base::g()
sizeof(*this) : 4   // why 4 bytes not 8 bytes?????????
Derived::f()
</code></pre>

<p>If <code>this</code> is pointing to the calling object, should the second line of <code>sizeof(*this)</code> print 8 instead of 4 since the calling object is <code>b</code>?  What actually is happening here? Is <code>this</code> has been demoted?!!!!</p>

<p>If <code>this</code> has been demoted to type <code>Base</code>, how <code>this-&gt;f()</code> invokes the correct function? I am really confused.</p>
