#include
using namespace std;
class BaseClass {
protected:
int i, j; // private to BaseClass, but accessible to D
public:
void set(int a, int b) {
i = a;
j = b;
}
void show() {
cout << i << " " << j << endl;
}
};
class DerivedClass : public BaseClass {
int k;
public:
void setk() { // DerivedClass may access BaseClass's i and j
k = i * j;
}
void showk() {
cout << k << endl;
}
};
int main()
{
DerivedClass object;
object.set(2, 3); // OK, set() is public in BaseClass
object.show(); // OK, show is public BaseClass
object.setk();
object.showk();
return 0;
}