【发布时间】:2016-08-17 13:41:30
【问题描述】:
如果我没有指定对 Base** 的显式强制转换,为什么会出现编译错误?
在处理派生类时可以使用指向指针的指针吗?
class Base { };
class Child : public Base { };
void SomeFunction(Base** ppoObj) {}
void SomeFunction(Base* poObj) {}
int main()
{
Child *c = new Child();
// This passed.
SomeFunction(c);
SomeFunction((Base**)&c);
// CompilationError
SomeFunction(&c);
return 0;
}
【问题讨论】:
标签: c++ pointers inheritance casting