[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppVclGraphics » sourcecode » VisualCSharp » STL » Notepad » BeginnersGuideToVB » BeginnersGuideToCSharp » CReturn » Allegro » QbasicFAQ_WhereDoIFindIt » CppProtected
The protected member variables and functions of a class can only be used from within a derived class. From outside the class, protected members are not accessable.
The code below shows class access:
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppVclGraphics » sourcecode » VisualCSharp » STL » Notepad » BeginnersGuideToVB » BeginnersGuideToCSharp » CReturn » Allegro » QbasicFAQ_WhereDoIFindIt » CppProtected
(C++) protected
Keyword indicating the level of class access.The protected member variables and functions of a class can only be used from within a derived class. From outside the class, protected members are not accessable.
The code below shows class access:
class Base
{
public:
int mBasePublic;
protected:
int mBaseProtected;
private:
int mBasePrivate;
};
//The class Derived inherits publicly from class Base
//In this example, however, the type of inheritance does not matter:
//Base's protected members get accessable in this class in all cases
class Derived : public Base
{
public:
int mDerivedPublicPublic;
protected:
int mDerivedPublicProtected;
private:
int mDerivedPublicPrivate;
void testBaseAccess() const
{
//BasePublic is accessable from inside any derived class
this->mBasePublic;
//BaseProtected gets accessable from inside any derived class
this->mBaseProtected;
}
};
'protected' links
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
