【发布时间】:2018-05-24 16:00:28
【问题描述】:
假设我有两个类:
class base
{
int hello;
public:
base
{
hello=5;
}
void show()
{
cout<<hello;
}
};
class derived:public hello
{
int hello;
public:
derived()
{
hello=2;
}
show();
};
现在我想知道它会显示 2 还是 5 ?如果是这样,那为什么以及如何让它反过来呢?
【问题讨论】:
-
您是否尝试编译并运行代码?
-
不在电脑自动取款机上,所以无法编译,必须在手机屏幕上全部输入
-
如果您要问技术问题,您应该坐在可以编译构成问题一部分的代码的计算机前,而不是使用手机。
标签: c++