【发布时间】:2015-04-11 14:45:03
【问题描述】:
我有以下代码:
class C {
public:
C(int) {}
C(const C&) {}
C() {}
};
class D : public C {
public:
using C::C;
};
int main() {
C c;
D d_from_c(c); // does not compile, copy ctor is not inherited
D d_from_int(1); // compiles, C(int) is inherited
}
派生类应该继承除默认ctor之外的所有基础ctor(解释here)。但是为什么copy ctor也没有被继承呢?此处不接受来自相关问题的参数。
代码使用g++ 4.8.1编译。
【问题讨论】:
标签: c++ c++11 inheritance copy-constructor