Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
是否总是需要从派生类构造函数调用基类构造函数?当你不调用它时会发生什么?
假设您正在谈论 C++(无论如何,这在大多数其他语言中应该类似),如果您不显式调用基类的构造函数,则会自动调用其默认构造函数(如果存在;如果不存在,则编译器会引发错误)。
什么都没有,因为绝对不可能不这样做。