inherited-constructors相关内容
struct B { B(int) {} B(B const&) {} }; struct D: B { using B::B; }; int main(void) { B b(5); D d(b); // error return 0; } c++14在12.9[class.inhctor]/p3中明确从继承的构造函数中排除复制/移动构造函数。 对于继承的候
..
我不明白为什么你不能编译一个类,它有一个成员(不可默认构造)和一个大括号或等号初始值设定项和一个继承的构造函数.g++ 说: test.cpp:22:15: 错误:使用已删除的函数‘Derived::Derived(float)’ 导出 d(1.2f); test.cpp:16:13:注意:‘Derived::Derived(float)’被隐式删除 因为默认定义格式不正确: 使
..
对于以下程序: #include struct Foo { Foo() { std::cout
..
如 [namespace.udecl]/18 所述: [...]命名构造函数的使用声明不会创建同义词.相反,如果其他构造函数在构造相应基类的对象时可以访问,则可以访问这些附加构造函数,并且using-声明的可访问性将被忽略. [...] 因此,以下代码无法编译: class B { protected: B(int) { } }; class D: B { using B::B;
..
我知道默认构造函数不是继承的,如 n3337 。 有一个例子: struct B2 { B2(int = 13,int = 42); }; struct D2:B2 { using B2 :: B2; }; 有很好的解释: D2 中 B2 的候选继承构造函数集为 ... -B2(int = 13,int = 42)
..
这里是类foo: template struct foo { foo() { t = nullptr; } foo(T * p,bool flag) { t = p; } private: T * t; }; 以下是类别栏: template struct bar:pu
..
我不明白为什么你不能编译一个类,它有一个成员(不是默认可构造)与一个大括号初始值设定器和一个继承的构造函数。 g ++说: test.cpp:22:15:error:使用已删除的函数'Derived :: Derived > 派生d(1.2f); test.cpp:16:13:note:'Derived :: Derived(float)'被隐式删除 ,因为默认定义是错误:
..