C++ Combination
Combination as a common English word means to combining something, In OOP combination means linking of two classes or combining two classes in such a way that the public features of one class can be called by another class ,People use to mix up between the concept of Inheritance and Combination but they are two different things in combination, when we will link two or more classes the object that we will use for call will be of final declared class in hierarchy of declared classes.
Now how to combine?
Simply we will declare the object of one class in public of another class in hierarchy downwards and if there are more then two class we will keep declaring in the classes of our choice or of which data we want to combine and then use.
How to call in main body?
As we now know that we will make an object of the final class in Hierarchy of classes, We will first write the Object name then we will give the access of member of other class by putting the member access operator and then the object of other class that was declared in final class through this we will get the access of public Data members or Datatypes of that class.From following example it will be further cleared .
0 comments:
Post a Comment