【发布时间】:2010-01-13 15:44:08
【问题描述】:
已解决
当我尝试编译这个程序时,我不断收到这些错误:
(50):错误 C2059:语法错误: '
(50) : 错误 C2143: 语法错误 : 失踪 ';'在'{'之前
(51) : 错误 C2059:语法错误:'>'
(51) : 错误 C2143:语法错误:缺少“;” 在'{'之前
(62) : 错误 C2059: 语法 错误:“其他”
(62) : 错误 C2143: 语法错误:缺少 ';'在'{'之前
#include <iostream>
#include <string>
#include <cassert>
using namespace std;
class income {
private:
double incm;
double subtract;
double taxRate;
double add;
char status;
public:
void setStatus ( char stats ) { status = stats; }
void setIncm (double in ) { incm = in; }
void setSubtract ( double sub ) { subtract = sub; }
void setTaxRate ( double rate ) { taxRate = rate; }
void setAdd ( double Add ) { add = Add; }
char getStatus () { return status; }
double getIncm () { return incm; }
double getsubtract () { return subtract; }
double getTaxRate () { return taxRate; }
double getAdd () { return add; }
void calcIncome ();
};
//calcIncome
int main () {
income _new;
double ajIncome = 0, _incm = 0;
char status = ' ';
bool done = false;
while ( !done ) {
cout << "Please enter your TAXABLE INCOME:\n" << endl;
cin >> _incm;
if(cin.fail()) { cin.clear(); }
if ( _incm <= 0) { cout << "the income must be greater than 0... \n" << endl; }
if ( _incm > 0) { done = true; _new.setIncm(_incm); }
}
done = false;
char stt [2] = " ";
while ( !done ) {
cout << "Please declare weather you are filing taxes jointly or single" << "\n";
cout << "\t's' = single\n\t'm' = married" << endl;
cin >> stt;
if(cin.fail()) { cin.clear(); }
if ( status == 's' || status == 'm' ) { done = true; _new.setStatus(stt[0]); }
//if else { }
}
return 0;
};
这是家庭作业的一部分,所以任何关于改进我的编程的建议都会是**好**
注意:我正在使用带有 VS express C++ 2008 的 Windows 7
【问题讨论】:
-
您应该避免使用以下划线开头的名称 (
_)。此类名称保留供编译器在内部使用。 (例如用于添加__declspec等功能) -
@Wallter,最好将代码保留在您最初发布的问题中。如果您将我的答案中的代码复制到您的问题中,那么该问题对未来的读者没有意义,因为您已经更正了代码并删除了您所询问的问题。
-
不是开玩笑,但你拼写是否错误。 :) 至少我认为你做到了。
标签: c++ compiler-errors