#include <iostream>
using namespace std;
class base {
private:
int i;
public:
int j, k;
void seti(int x) { i = x; }
int geti() { return i; }
};
class derived: private base {
public:
base::j;
base::seti;
base::geti;
int a;
};
int main()
{
derived ob;
ob.j = 20; // legal because j is made public in derived
//ob.k = 30; // illegal because k is private in derived
ob.a = 40; // legal because a is public in derived
ob.seti(10);
cout << ob.geti() << " " << ob.j << " " << ob.a;
return 0;
}
|