按要求补充编程片段 只要符合标准 秒采纳(必须按照他提示的进行编写)

img

img


类与对象不要用太高级句子 按照他的提示填写 最好附上运行结果 只要测试后没问题 秒通过!

你题目的解答代码如下:

#include<iostream>
#include<string.h>
using namespace std;

class Car
{
private:
    int no;
    char color[10];
    int old;

public:
    static int count;
public:
    Car(int n, char *c, int o)
    {
        no = n;
        strcpy(color,c);
        old = o;
        count++;
    }
    ~Car()
    {
        count--;
    }
    int getOld()
    {
        return old;
    }
    void display()
    {
        printf("%d %s %d\n", no,color,old);
    }
    static void displayCount()
    {
        printf("%d\n", count);
    }
};
int Car::count=0;

int main()
{
    int no;
    char color[10];
    int old;
    int i = 0;
    Car *cars[100],*max;
    scanf("%d%s%d", &no,color,&old);
    while (no!=0)
    {
        cars[i] = new Car(no,color,old);
        if (i==0 || max->getOld() < cars[i]->getOld())
            max = cars[i];
        i++;
        scanf("%d%s%d", &no,color,&old);
    }
    max->display();
    Car::displayCount();
    return 0;
}

如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!

img

您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!
PS:问答VIP年卡 【限时加赠:IT技术图书免费领】,了解详情>>> https://vip.csdn.net/askvip?utm_source=1146287632