I give one example .
class parent
{
protected int a;
}
class child : parent
{
void fun()
{
parent p = new parent();
p.a = 10; //Error Cannot access protected member through parent object
a = 10; //NO error .We can access protected member through inheritance hierarchy.
}
}
class parent
{
protected int a;
}
class child : parent
{
void fun()
{
parent p = new parent();
p.a = 10; //Error Cannot access protected member through parent object
a = 10; //NO error .We can access protected member through inheritance hierarchy.
}
}
No comments:
Post a Comment