Answer the question
In order to leave comments, you need to log in
How to correctly choose whether to inherit a class or pass a pointer to a class?
There is a class responsible for connecting to the database. Separately, there is a class that generates a request. Does it make sense to use inheritance or is it better to pass a connection reference to the request?
Answer the question
In order to leave comments, you need to log in
https://ru.wikipedia.org/wiki/Substitution_principle_...
Mandatory question in any C++ interview :)
C++ allows you to implement things in a hundred ways. Therefore, it is better for yourself or the team to agree in advance what and how you are doing.
In fact, you can come up with a rule for yourself without any basic and distant reality principles like SOLID. In itself, inheritance in 90% of cases is necessary for the implementation of the interface. The remaining 10% fall into various C++ features. In some languages, there is no inheritance at all, but this does not prevent them from being OOP and writing beautifully.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question