I have a base class that contains only its own default constructor and the open remote copy constructor, and nothing more.
class base { private: base() = default; public: base(const base&) = delete; };
If I try to inherit from base and create an instance of the derived class, as shown below, g ++ 4.8.2 does not compile my code, but VC ++ 2013 does.
class derived : public base { private: derived() = default; }; derived x;
So, is this a bug in g ++ or VC ++ 2013 just ignored something?
Here's the full code ...
class base { private: base() = default; public: base(const base&) = delete; }; class derived : public base { private: derived() = default; }; derived x; int main() { }
... and g ++ error message.
main.cpp:12:5: error: 'constexpr derived::derived()' is private derived() = default; ^ main.cpp:15:9: error: within this context derived x; ^ main.cpp: In constructor 'constexpr derived::derived()': main.cpp:3:5: error: 'constexpr base::base()' is private base() = default; ^ main.cpp:12:5: error: within this context derived() = default; ^ main.cpp: At global scope: main.cpp:15:9: note: synthesized method 'constexpr derived::derived()' first required here derived x; ^
so61pi
source share