Reputation: 97
Is it always necessary to call base class constructor from derived class constructor? What happens when you don't call it?
Upvotes: 5
Views: 4425
Reputation: 40849
Nothing at all, since it's absolutely impossible not to do so.
Upvotes: -2
Reputation: 4341
Assuming you're talking about C++ (anyway, this should be similar in most other languages), if you don't call a constructor of the base class explicitly, its default constructor will be called automatically (if one exists; if not, the compiler would fire an error).
Upvotes: 10