2 ms·
class foo { foo() = default; ~foo() = default; }; Is actually the idiomatic version of that C++ class, far less repetitive.
by NikkiA 7y ago
class foo {
foo() = default;
~foo() = default;
};
Is actually the idiomatic version of that C++ class, far less repetitive.
- kazinator 7y agoThe class I wrote has a non-default constructor and destructor. The idiomatic way to write your class is just: class foo { }; allowing the compiler to supply the default constructor and destructor. The purpose of the C++11 default mechanism is to request a default implementation of a special function in situations when it would be suppressed. For instance class foo { public: foo(int x); // this will suppress the default constructor foo() = default; // this requests it back };