Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Things that cannot be inherited

I've been asked to name three things that can not be inherited from the base class.

Apart from private member functions, what else can I add?

I thought about friend functions but since they don't actually belong to the class, they have nothing to do with inheritance.

like image 890
Max Avatar asked Feb 21 '23 05:02

Max


1 Answers

A few obvious ones you usually care about are constructors, assignment operators and destructors.

In all these cases, a new version specific to the derived class is either provided by the user, or else synthesized by the compiler (though C++11 also adds some capabilities for things like simply deleting one that you don't want available).

I should probably add that "can not be inherited" isn't necessarily exactly correct. For example, C++11 adds inheriting constructors (but they weren't in C++98/03, which is what most courses still deal with). Even in C++11, you don't inherit them by default.

like image 158
Jerry Coffin Avatar answered Feb 22 '23 18:02

Jerry Coffin