cod*_*ver 10 c++ inheritance public visual-c++
我的情况如下::
class Parent
{
public:
int x;
}
class Child:public Parent
{
int x; // Same name as Parent's "x".
void Func()
{
this.x = Parent::x; // HOW should I access Parents "x".
}
}
Run Code Online (Sandbox Code Playgroud)
这里是如何从Child的成员函数访问Parent的"X".
Luc*_*ore 10
几乎得到了它:
this->x = Parent::x;
Run Code Online (Sandbox Code Playgroud)
this 是一个指针.