by Dinesh Thakur Category: Classes in C++

In the Hierarchical Inheritance, when we use The Same Data Member in the Sub Class Then the Data Member will Contains the Many values So that here Data Member will be Ambiguous Because a Single Data Member have two or more values.

 As we are seeing in this diagram that the First Class is used by second, third and also by fourth. So that data Members will also be used by the Second, Third and Fourth classes. So that they can also provides the different values to the Data Members of First Class , So that the First Class data Members will Contains Many Values and this will Create the Complexity for the Compiler. And also create the Ambiguity for the Compiler.

     So for Avoiding Ambiguity we use the Virtual in inheritance Means When we inherit the Base Class as a Virtual then all the Data can be Override by the Sub Class the Value of Data Member will be determined by the Last inherited Class.

 

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content







Popular Article