【发布时间】:2021-10-22 16:47:17
【问题描述】:
// c++ class inheritance
#include<iostream>
using namespace std;
class A
{
public:
int x;
};
class B: public A
{
};
int main()
{
B b;
b.x=5;
cout<<b.x<<endl;
return 0;
}
派生类是否为继承的变量分配内存,或者它只是从基类中访问它??
【问题讨论】:
标签: c++ oop inheritance memory allocation