注册 登录
编程论坛 C++教室

请问错误是怎么回事

a99875984 发布于 2012-05-31 14:56, 378 次点击
源代码是:
程序代码:
#include<iostream>
#include <iomanip>
#include <math.h>
using namespace std;
class sanjiaoxing
{
private:
    double x,y,z;
public:
    void shuru(double a,double b,double c);
    void mianji();
    void chouchang();
};
void sanjiaoxing::shuru(double a,double b,double c)
{
    x=a;
    y=b;
    z=c;
}
void sanjiaoxing::chouchang()
{
    cout<<x+y+z<<endl;
}
void sanjiaoxing::mianji()
{
    int d,e,f,g;
    d=1/(2*(x+y+z));
    e=sqrt(d*(d-x)*(d-y)*(d-z));
    cout<<g<<endl;
}
void main()
{
    sanjiaoxing 1;//error C2143: syntax error : missing ';' before 'constant'
    int a,b,c,i;
    cin>>a>>b>>c;
    1.shuru(a,b,c);//error C2059: syntax error : 'bad suffix on number'error C2146: syntax error : missing ';' before identifier 'shuru'还有个shuru未定义
    1.chouchang();//和上行差不多的错误提示
    1.mianji();//和上行差不多的错误提示
}


[ 本帖最后由 a99875984 于 2012-5-31 15:21 编辑 ]
2 回复
#2
yuccn2012-05-31 15:31
你那个是数字吧 数字不能作为变量
#3
a998759842012-05-31 15:39
回复 2楼 yuccn
谢谢了,我不知道那是变量,每次为了图方便,我就用数字,没想到会出现这种错误,谢谢了
1