大家帮我编译一下 是否我的编译器有错

来源:百度知道 编辑:UC知道 时间:2024/05/18 02:53:50
#include<iostream>
using namespace std;
class Money
{
public:
friend Money operator +(Money& amount1,Money& amount2);

Money(long doallars,int cents);

void get_write();
private:
long all_cents;
};

int main()
{
Money cost(1,50),tax(0,15),total;
total=cost+tax;
total.write();
return 0;
}

Money::money(long dollars,int cents)
{
all_cents=100*dollars+cents;
}
Money operator +(Money& amount1,Money& amount2)
{
Money temp;
temp.all_cents=amount1.get_write()+amount2.get_write();
return temp;
}
void Money::write()
{
cout<<all_cents;
}
void Money::get_write()
{
return all_cents;
}
D:\Microsoft Visual Studio\MyProjects\试错题\lihui.cpp(7) : error C2804: binary 'operator +' has too many parameters
D:\Microsoft Visual Stud

错误很多

1.没有默认构造函数.因此temp,total这两个变量的声明会出错
2.有个Money你写成money了
3.write函数未在类中声明
4.get_write函数返回类型应该是long

fatal error C1001: INTERNAL COMPILER ERROR
(compiler file 'msc1.cpp', line 1786)
Please choose the Technical Support command on the Visual C++
Help menu, or open the Technical Support help file for more information
执行 cl.exe 时出错.