We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1fe2b00 commit badf4d8Copy full SHA for badf4d8
practical_exercises/10_day_practice/day5/继承访问权限/私有继承.cpp
@@ -7,9 +7,9 @@ class Base{
7
int getx(){return x; }
8
void showx(){cout<<x<<endl; }
9
};
10
-//私有继承
11
-//基类的中的public成员在派生类中是private, private成员在派生类中不可访问。
12
-class derived:private base{
+//私有继承
+//基类的中的public成员在派生类中是private, private成员在派生类中不可访问。
+class derived:private Base{
13
int y;
14
public:
15
void sety(int n){y=n; }
@@ -22,5 +22,4 @@ int main(){
22
obj.sety(20);
23
obj.showx();//cannot access
24
obj.showy();
25
- system("pause");
26
}
0 commit comments