Inheritance in programming implies an extension of the functional, and not vice versa. Thus, during inheritance, we can add new properties and methods to the inheriting classes, but we cannot remove something defined in the ancestor class. The maximum that we can do is to define a method or property as private, as already written by @cheops , however this does not mean the private element will not be inherited, it will simply not be available for direct reference in the heir classes, but will be inherited in any case.
If you have a situation when you need to prohibit the inheritance of individual elements - this may mean one of two things: either the ancestor class is not correctly selected, or an error in designing the inheritance tree.
For completeness, it is worth noting that in some languages individual elements may not be inherited, BUT, such elements of classes and their features during inheritance are determined by the language specification, they are constant for all classes in a given language, and this behavior cannot be controlled from code. As an example, I can give the lack of inheritance of static class elements in C #.
UPD: A constructor, like a destructor, is an infrastructural method and, despite what is defined in the class code, is not fully a method of this class, because it cannot be accessed through either the instance or the class itself. The only way to contact the constructor is with special language instructions for placing a new object. In different languages, the behavior of constructors when inheriting is different, for example, C # consistently calls the constructors of all base classes, so the child class may not have its own constructor. But in fact, the constructor is not inherited.
As for the comparison of inheritance, as the principle of the OOP with the inheritance in life, this is a common misconception, which is discussed with varying degrees of detail in any less serious book on the PLO. In general, in life you can find a lot of examples of inheritance, which cannot be reproduced by means of program inheritance, in different cases go out of the situation in different ways, for example, by defining a set of interfaces instead of an inheritance tree.
@strangeqargo
... You can add functions (there will be more functions in the inheriting class), but this does not mean that the heir will have more capabilities than the ancestor. if you inherit a car: vehicle, the car will be "more specific" than the vehicle and cannot swim / fly / teleport, although the vehicle can.
You are right, but only in part. Yes, in the base class we define only the перемещение method common for the whole transport, and this will be the very generalization without specifics you are talking about, BUT, when it comes to the actual movement of the object, we will need specifics how to drive, on what principle fly, what forces teleport. And in this case, to say that the class vehicle can more than car not entirely correct, yes, theoretically, it can do everything, but until the corresponding derived classes are created to implement this or that, or even all of the movement functions, it actually cannot . Moreover, this example should rather be attributed to the principle of polymorphism, since No one will forbid me to define a flight as one of the possible options for moving a car.
@Alexandr Karpulix
For example, soft clay. It has a property that helps to take its any form. All products from it are her direct heir, having the same chemical composition and, possibly, color. But her softness is available only in her parent class, the products are hard.
The softness in this case is a property and not a method, this is the difference. A piece of clay can be put in the oven and change this property, it will become hard, remaining the same piece of clay, as well as the unfired pot will remain soft as the source material, while remaining a specific clay product. Properties can determine the applicability of a particular object in a particular case, do not change the essence of the object. If the pot is intended for storing liquid, then it is not important whether it is soft or solid, it will fulfill its task. Again, in this case, you should not consider the pot as a derivative of clay. Clay, pot material. No one bothers to hollow out the same pot of wood. At the same time, it will cease to be clay, but it will remain a pot, which means the material is a property.
PS: I apologize for the lecture%)