#include <iostream>
using namespace std;
class BaseClass {
int i, j;
public:
void set(int a, int b) {
i = a;
j = b;
}
void show() {
cout << i << " " << j << endl;
}
};
class DerivedClass : public BaseClass {
int k;
public:
DerivedClass(int x) {
k = x;
}
void showk() {
cout << k << endl;
}
};
int main()
{
DerivedClass ob(3);
ob.set(1, 2); // access member of BaseClass
ob.show(); // access member of BaseClass
ob.showk(); // uses member of DerivedClass class
return 0;
}
|