开发者

What happens if you don't call the base constructor from the derived constructor?

开发者 https://www.devze.com 2023-01-28 19:24 出处:网络
Is it always necessary to call base class constructor from derived class constructor?What happens whe开发者_如何学Cn you don\'t call it?Assuming you\'re talking about C++ (anyway, this should be simil

Is it always necessary to call base class constructor from derived class constructor? What happens whe开发者_如何学Cn you don't call it?


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).


Nothing at all, since it's absolutely impossible not to do so.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号