Login    New User    Forgot Password    Help      

Data Hiding in Inheritance

GO TO INDEX

Data Hiding in Inheritance

Private variables and methods are seen only the class they are declared in, but sometimes you want to give derived classes the right to access the variable or method while blocking others out. To do this you use keyword protected, rather than making the variable or method private. This allows derived classes to access the variable, and when the class is derived as public, as in the previous example, the derived class accepts that. If the class was declared like "class BarWindow : private Window" then it could not see the protected variables/methods. Below is a chart showing what you can access and when:

Inheritance-Mode

GO TO INDEX