问题描述
class A
{
public:
A() {}
void run() {};
};
class B : private A
{
public:
B() {}
using A::run; (1)
using A::A; (2)
};
int main()
{
//A* a = new B; // not compile (3)
B b;
b.run();
}
为什么我不能在(3)中使用多态?
即使在 (2) 中添加 using A::A;
后,它也不会编译。我预计它会在 (2) 中添加 using A::A;
后与 (1) 中的 using A::run
一样编译,但不幸的是,它没有编译。
如何解释 (3) 中的这一行,从而导致这种行为?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)