Access specifier and mode
narendra
c_cpp
a year ago
541 B
16
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;
}Editor is loading...
Leave a Comment