关于子类调用父类成员的this指针问题

#include <iostream>
using namespace std;

class A
{
public:
    A()
    {
        a = 10;
    }
    void show()
    {
        cout << a;
    }

private:
    int a;
};
class B : public A
{
public:
    B()
    {
        a = 100;
    }
private:
    int a;
};
int main()
{
    B p;
    p.show();
    return 0;
}

我以为输出的是B中的a=100,结果输出的是A中的a=10; 但是我觉得在调用show()函数时候传入的是B中的this,而且我记得在B中想访问A中的重名变量得加访问域A::才行吧。 所以为什么输出10呢?

当然是输出基类中的a了,基类不可能认识子类的a变量啊,而且还是私有的

关键是你的show是在A类里面的,,,,