为什么这样的代码:class A{ public: display: display: display; };class B: public A{};int main(void){ B *b = new B(5); delete b;} 会导致这些错误:main.cpp: In fun...
为什么这样的代码:
class A
{
public:
explicit A(int x) {}
};
class B: public A
{
};
int main(void)
{
B *b = new B(5);
delete b;
}
导致这些错误:
main.cpp: In function ‘int main()’: main.cpp:13: error: no matching function for call to ‘B::B(int)’ main.cpp:8: note: candidates are: B::B() main.cpp:8: note: B::B(const B&)
B 不应该继承 A 的构造函数吗?
(这是使用 gcc)