C++ examples for Class:Member Access
Using Protected Members to let base classes provide derived classes with access to some of their private member data or functions.
#include <cstdlib> #include <iostream> using namespace std; class base // w w w . ja va2 s . co m { protected : int anInt; }; class derived : public base { public : void AFunction(int theInt); }; inline void derived ::AFunction(int theInt) { anInt = theInt; cout << anInt << endl; } int main(int argc, char *argv []) { derived temp; temp.AFunction(5); return 0; }