c++程序 改错
答案:3 悬赏:70 手机版
解决时间 2021-04-05 12:30
- 提问者网友:暮烟疏雨之际
- 2021-04-05 07:52
c++程序 改错
最佳答案
- 五星知识达人网友:詩光轨車
- 2021-04-05 09:05
#include
#include
class highway
{int car;int carfee;
int bus;int busfee;
int truck;int truckfee;
int a,b,c;
public:
highway()
{car=bus=truck=0;
}
int Q;
highway(int x,int y,int z)
{
car=x;
bus=y;
truck=z;
}
~highway(){}
void car_increment();
void bus_increment();
void truck_increment();
void income();
void process();
};
void highway::car_increment(){car++;};
void highway::bus_increment(){bus++;};
void highway::truck_increment(){truck++;};
void highway::income(){Q=car*5+bus*15+truck*25; cout<<"您的总过路费为 : "<void highway::process()
{char ch;
cout<<"欢迎来到高速公路收费站"< cout<<"**********************\n"< cout<<" 小车过路:请击1 "< cout<<" 客车过路:请击2 "< cout<<" 货车过路:请击3 "< cout<<" 退出并统计:请击0 "< cout<<"**********************\n"< cout<<"请输入您的选择:"< cin>>ch;
switch(ch)
{
case '1':car_increment();break;
case '2':bus_increment();break;
case '3':truck_increment();break;
case '0':income();break;
}
cout< }
void main()
{
highway X;
while(1)
{
X.process();cout<<"卢姣 080806110103"< }
}
#include
class highway
{int car;int carfee;
int bus;int busfee;
int truck;int truckfee;
int a,b,c;
public:
highway()
{car=bus=truck=0;
}
int Q;
highway(int x,int y,int z)
{
car=x;
bus=y;
truck=z;
}
~highway(){}
void car_increment();
void bus_increment();
void truck_increment();
void income();
void process();
};
void highway::car_increment(){car++;};
void highway::bus_increment(){bus++;};
void highway::truck_increment(){truck++;};
void highway::income(){Q=car*5+bus*15+truck*25; cout<<"您的总过路费为 : "<void highway::process()
{char ch;
cout<<"欢迎来到高速公路收费站"<
switch(ch)
{
case '1':car_increment();break;
case '2':bus_increment();break;
case '3':truck_increment();break;
case '0':income();break;
}
cout<
void main()
{
highway X;
while(1)
{
X.process();cout<<"卢姣 080806110103"<
}
全部回答
- 1楼网友:一叶十三刺
- 2021-04-05 10:24
highway类的成员变量没有初始化。
无参构造函数里也加一句的car=carfee=bus=busfee=truck=truckfee=0;
无参构造函数里也加一句的car=carfee=bus=busfee=truck=truckfee=0;
- 2楼网友:十鸦
- 2021-04-05 09:23
#include
class highway
{int car;
int bus;
int truck;
//int a,b,c;
public:
// highway(){}
int Q;
highway()
{
car=bus=truck=0;
//a=x;b=y;c=z;
}
~highway(){cout<<"卢姣 080806110103"< void car_increment();
void bus_increment();
void truck_increment();
void income();
void process();
};
void highway::car_increment(){++car;Q+=5;cout<<"已经"< void highway::bus_increment(){++bus;Q+=15;cout<<"已经"< void highway::truck_increment(){++truck;Q+=25;cout<<"已经"< void highway::income(){cout<<"Q="<void highway::process()
{//char ch;
int ch;
cout<<"欢迎来到高速公路收费站"< cout<<"**********************\n"< cout<<" 小车过路:请击1 "< cout<<" 客车过路:请击2 "< cout<<" 货车过路:请击3 "< cout<<" 退出并统计:请击0 "< cout<<"**********************\n"< cout<<"请输入您的选择:"< cin>>ch;
switch(ch)
{
case 1:car_increment();break;
case 2:bus_increment();break;
case 3:truck_increment();break;
case 0:income();break;
}
cout< }
void main()
{ static highway X;
X.Q=100;
while(1)
{
cout<<"给出收费站目前收款状况:"<< X.Q<
X.process();
}
} 我按我所了解去修改,意思应该能表达了
class highway
{int car;
int bus;
int truck;
//int a,b,c;
public:
// highway(){}
int Q;
highway()
{
car=bus=truck=0;
//a=x;b=y;c=z;
}
~highway(){cout<<"卢姣 080806110103"<
void bus_increment();
void truck_increment();
void income();
void process();
};
void highway::car_increment(){++car;Q+=5;cout<<"已经"<
{//char ch;
int ch;
cout<<"欢迎来到高速公路收费站"<
switch(ch)
{
case 1:car_increment();break;
case 2:bus_increment();break;
case 3:truck_increment();break;
case 0:income();break;
}
cout<
void main()
{ static highway X;
X.Q=100;
while(1)
{
cout<<"给出收费站目前收款状况:"<< X.Q<
X.process();
}
} 我按我所了解去修改,意思应该能表达了
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯