Skip to content

Commit badf4d8

Browse files
authored
Update 私有继承.cpp
1 parent 1fe2b00 commit badf4d8

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

practical_exercises/10_day_practice/day5/继承访问权限/私有继承.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ class Base{
77
int getx(){return x; }
88
void showx(){cout<<x<<endl; }
99
};
10-
//私有继承
11-
//基类的中的public成员在派生类中是private, private成员在派生类中不可访问。
12-
class derived:private base{
10+
//私有继承
11+
//基类的中的public成员在派生类中是private, private成员在派生类中不可访问。
12+
class derived:private Base{
1313
int y;
1414
public:
1515
void sety(int n){y=n; }
@@ -22,5 +22,4 @@ int main(){
2222
obj.sety(20);
2323
obj.showx();//cannot access
2424
obj.showy();
25-
system("pause");
2625
}

0 commit comments

Comments
 (0)