[ppt] public 상속 접근제어


[ppt] public 상속 접근제어

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 #include <iostream> using std::cout; using std::endl; class A // 기본 클래스 { int x; public: void SetX(int i) { x = i; } void ShowX() { cout << x << endl; } }; class B :public A //파생 클래스 { int y; public: void SetY(int i) { y = i; } void ShowY() { cout << y << endl; } }; void main() { B bb; //파생클래스의 객체 //bb.x = 1;// B 클래스는 A를 상속받을때 x는 private 이기 때문에 상속받지 못함 bb.SetX(1); //bb.y = 2;//Y는b클래스에 private이기 때문에 캡슐화에 맞지않아 상속불가능 bb.S...



원문링크 : [ppt] public 상속 접근제어