欢迎光临散文网 会员登陆 & 注册

自考04737 C++ 2022年10月37题答案

2023-04-09 16:38 作者:穷逼不逼  | 我要投稿

点赞、投币有什么用 ?让我体验体验 !


#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;
}


自考04737 C++ 2022年10月37题答案的评论 (共 条)

分享到微博请遵守国家法律