Suppose, I write
class A { };
The compiler should provide (as and when needed)
- a constructor
- a destructor
- a copy constructor
- = operator
Is this all the compiler provides? Are there any additions or deletions to this list?
It's complete. But there are two points you should note:
Some explanation for 2:
struct A { private: A(); };
struct B : A { };
That's fine! Providing a default constructor would be ill-formed for "B", because it would not be able to call the base-class' constructor. But the default constructor (and the other special functions) is only provided (we say it's implicitly defined) if it's actually needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With