你题目的解答代码如下:
#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;
}
您好,我是有问必答小助手,您的问题已经有小伙伴帮您解答,感谢您对有问必答的支持与关注!如有帮助,请点击我的回答下方的【采纳该答案】按钮帮忙采纳下,谢谢!