c++ - private inheritance and composion, which one is best and why? -


Assume that I have a class engine and I get a class car from the indin class

< Pre> class engine {public: engine (int louoscillilander); Zero starting (); }; Class car: private industry {public: car (): e (8) {} zero start () {estart (); } Private: engin e; };

Now the structure can be done, the question is which approach would be best and most of it is used in programming, and why ???????

I like to think about heritage because is a kind of derivative basis , which originally meant the public succession. In the case of personal heritage, this is a more derivative basis , which IMHO does not speak right, because it is not the work of creation for any kind of heritage. Therefore, because private heritage and structure are compulsory What is the meaning of the same thing in the logical form, which is to choose? For example, if you have posted, I will definitely go for the structure. I think of all types of heritage as a type of relationship, and have posted with examples, I can not think of a situation where I can say that a car in a way The engine is of , it is not just this is an engine near a car , then why would one car pass a car? I do not see any reason

Now, there are actually cases where there is a private succession, i.e., promotion: noncompable, with its protector / guardian being protected, you want it to be hard It's time, and in fact since we want our class to be a non-cockpit part in , this is the only way.

Use some style guide (e.g., personal heritage), for reasons similar to what I have already written - personal heritage is just a bit confusing.

Hope this will be helpful.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -