自考04737 C++ 2022年10月37题答案
点赞、投币有什么用 ?让我体验体验 !
#include<iostream>
using namespace std;
class TwoCord {
private:
int x, y;
public:
TwoCord(int x, int yy) {
this->x = x; //填空1
y = yy;
}
void display() {
cout << "x=" << x << ",y=" << y;
}
};
class ThreeCord: public TwoCord { //题目有误!! 原题此仅为 class ThreeCord
int z; //没有访问修饰,则默认为 private
public:
ThreeCord(int x, int yy, int zz): TwoCord(x, yy) {
z = zz;
}
void display() {
TwoCord::display(); //填空2
cout << ",z=" << z;
}
};
int main() {
ThreeCord c(6, 8, 10);
c.display();
return 0;
}