#include #include //testClassPrivateProtected1.cpp using namespace std; typedef class A { private: int pvtnum1; protected: int procnum1; string str1; public: int pubnum1; string str2; void dosomething();// member function } pA; // class member accesing private //class aliast::memberfunction void pA::dosomething() { pvtnum1 = 200; procnum1 = 100; pubnum1 = 50; str1="Class instances can't access pvt member"; cout<<"\n private "<< pvtnum1; cout<<"\n , protected "<< procnum1; cout<<"\n , public "<< pubnum1; cout<<"\n ,"<< str1; } class B:public pA { public : void B_function() { str1 += "\n reappeared in B"; cout<<"\n, protected member of class A: "; cout<<" str1 "<< str1; } }; int main() { pA obj1;obj1.dosomething(); obj1.str2 += " public string variable"; B obj2; obj2.B_function(); cout<<"\n obj1.str2 : public member : "<< obj1.str2; return 0; }