+ 1
What does exactly the protected access specifier means
3 Antworten
+ 1
It actually not assess by dot operator but can be inserted in another class
eg. class A
{
int a;
public:
A()
{a=2;}
protected:
int c;
};
class B: public A
{ int x;
public:
B()
{x=c;} //will not produce any error
//because c is a protected member
};
void main()
{ A obj;
obj.a=2;. //error because a is private
obj.c=3;. //error because c is protected
B obj1;
}
+ 2
I hope these can help us learn:
http://www.geeksforgeeks.org/access-modifiers-in-c/
http://www.tutorialdost.com/Cpp-Programming-Tutorial/48-Cpp-Public-Private-Protected-Access-Modifiers.aspx
Hth, cmiiw
+ 1
Thanks brother