我有下面的代碼:複製構造是不能繼承
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
}
派生類要繼承基礎的所有構建函數,除了默認的構造函數(它被解釋here)。但爲什麼copy ctor還沒有被繼承?來自相關問題的爭論在這裏是不能接受的。
該代碼是用g ++ 4.8.1編譯的。