Access specifier and mode

 avatar
narendra
c_cpp
a month ago
541 B
1
Indexable
#include <iostream>
using namespace std;

class Parent{
  public:
    int x;
  
  protected:
    int y;
    
   private:
     int z;
};

class Child1 : public Parent{
  // x will remain public
  // y will remain protected
  // z will be not accessible 
  
};

class Child2 : protected Parent{
  // x will be protected
  // y will be protected
  // z will be inacceptable 
};

class Child3 : private Parent {
  // x will be private
  // y will be private
  // z will be inaccessible 
};


int main(){
  
  Parent p;
  p.x;
  
  
  return 0;
}
Leave a Comment