Posted on 2006-11-12 23:31
苑 阅读(136)
评论(0) 编辑 收藏 所属分类:
C++学习资料
#include <iostream>
using namespace std;
class BaseClass {
int i, j;
public:
BaseClass(int x, int y) {
i = x;
j = y;
}
void showij() {
cout << i << ' ' << j << '\n';
}
};
class DerivedClass : public BaseClass {
int k;
public:
DerivedClass(int a, int b, int c) : BaseClass(b, c) {
k = a;
}
void show() {
cout << k << ' '; showij();
}
};
int main()
{
DerivedClass ob(1, 2, 3);
ob.show();
return 0;
}