Here, we will discuss scope of the variables and functions declared in a base class and derived class. To illustrate this, let us take an example.
First, we deine a class
A
, which contains three variables having different visibility scope.
Then we define a subclass
B
which inherits the base class
A
using
public
scope.
We have commented the lines where variables are not accesssible.
If the class
B
inherits class
A
in protected mode, the variables and functions having
public
access in base class are inherited as protected members. Thus,
accessibility change is shown in the follwing code.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.