求助啊求助
以下是一个在VC++下编写的车辆收费系统,根据需要必须用TC++进行编译,谁能告诉我应该做怎样的改动?头文件:
#include "iostream.h"
namespace traff
{
class sum
{
int num;
int fee;
public:
sum();
void process(int change);
void display();
~sum();
};
}
cpp1.cpp文件
#include "sum.h"
using namespace std;
namespace traff
{
sum::sum()
{
num=0;
fee=0;
}
void sum::process(int change)
{
num=num+1;
fee=fee+change;
}
void sum::display()
{
cout <<"车辆总计:";
cout <<endl;
cout <<num;
cout <<endl;
cout <<"收费总计:";
cout <<endl;
cout <<fee;
cout <<endl;
}
sum::~sum()
{
;
}
}
主程序文件:
#include "cpp1.cpp"
#include "sum.h"
void proc(sum &car,sum &bus,sum &truck,sum &s)
{
cout <<"选择车型:"<<endl<<"1 小轿车 2 卡车 3公共汽车"<<endl;
int type;
cin >>type;
cin.get();
cout <<"收费:";
int change;
cin >>change;
cin.get();
switch (type)
{
case 1:
car.process(change);
s.process(change);
break;
case 2:
truck.process(change);
s.process(change);
break;
case 3:
bus.process(change);
s.process(change);
break;
default:
break;
}
}
void disp(sum &car,sum &bus,sum &truck,sum &s)
{
cout <<"选择车型:"<<endl<<"1 小轿车 2 卡车 3 公共汽车 4 总计"<<endl;
int type;
cin >>type;
cin.get();
switch (type)
{
case 1:
car.display();
break;
case 2:
truck.display();
break;
case 3:
bus.display();
break;
case 4:
s.display();
break;
default:
break;
}
}
int main()
{
cout <<"欢迎使用本系统!"<<endl;
sum car;
sum truck;
sum bus;
sum s;
int i;
for(i=0;i<10;i++)
{
cout <<"选择您要使用的功能:"<<endl;
cout <<"1 收费 2查看 3退出"<<endl;
int a;
cin >>a;
cin.get();
switch(a)
{
case 1:
{
proc(car,bus,truck,s);
i=1;
break;}
case 2:
{
disp(car,bus,truck,s);
i=1;
break;}
case 3:
i=11;
break;
default:
i=1;
break;
}
}
cout <<"欢迎使用本系统!"<<endl<<"再见!"<<endl;
return 0;
}