Inheritance Question
-
Hi, I have some questions about inheritance. For instance, I have a class A and it has one public method metPubA, one protected method metProA, one private method metPriA, one private int variable intPriA, one protected int variable intProA, one public int variable intPubA. I have derived a class B from A with public kind. In class B which methods and variables of A will be copied and can be usable? Is that possible to change the inside of intPriA from B without a public or protected method in class A that changes inside of intPriA? Lastly, if I create another derived class C from class B with public kind. The intPriA variables that class B, class A and class C has the same one or what? I mean if I change the intPriA from class B what will happen to class C one? I'm confused on this subject, any help would be appriciated also any good article that has explanation on this would be very very helpful. Kind Regards,
-
Hi, I have some questions about inheritance. For instance, I have a class A and it has one public method metPubA, one protected method metProA, one private method metPriA, one private int variable intPriA, one protected int variable intProA, one public int variable intPubA. I have derived a class B from A with public kind. In class B which methods and variables of A will be copied and can be usable? Is that possible to change the inside of intPriA from B without a public or protected method in class A that changes inside of intPriA? Lastly, if I create another derived class C from class B with public kind. The intPriA variables that class B, class A and class C has the same one or what? I mean if I change the intPriA from class B what will happen to class C one? I'm confused on this subject, any help would be appriciated also any good article that has explanation on this would be very very helpful. Kind Regards,
The rule for public inheritance is simple: private data/methods are not accessible to B protected data/methods remain protected in B public data/methods remain public in B So you can't change intPriA directly from B methods because intPriA is private. --Mike-- LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ Strange things are afoot at the U+004B U+20DD