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

这个简单的C++程序为什么会报错呢!求解

超神级 发布于 2013-09-08 21:25, 1229 次点击
程序代码:
#include <iostream>
using namespace std;
class  human
{
public:

    void get_stature(){cout<<stature;}
    void GetWeight();
    void SetStature(int x){stature=x;}  
private:
    int stature();
    int weight();
   
};

void main()
{
   human Mike;
   Mike.SetStature(8);
   Mike.get_stature();
}
15 回复
#2
超神级2013-09-08 21:44
没人理!各位大神求解
#3
超神级2013-09-08 22:10
哪里不对给个答案啊!本人新人一枚
#4
peach54602013-09-09 09:09
你自己看看错误提示是什么...
少个变量
#5
can39811322013-09-09 09:42
    void SetStature(int x){stature=x;}
哪来的stature?
#6
can39811322013-09-09 09:43
www.baidu.com度娘出手
#7
超神级2013-09-09 11:49
回复 4楼 peach5460
谢谢!我自己想到了!我写成void了改成int就好了
#8
超神级2013-09-09 11:51
回复 5楼 can3981132
上面的声明了啊
#9
超神级2013-09-09 11:51
回复 6楼 can3981132
/》》》》
#10
郁闷的终结2013-09-10 20:34
。。。。。》》》》》》
#11
peach54602013-09-11 06:16
回复 8楼 超神级
哪个上面声明了?我怎么没看到?
#12
Cai_xw19932013-09-11 14:12
程序代码:
#include <iostream>
using namespace std;
class  human
{
public:

    void get_stature(){cout<<stature;}
    void GetWeight();
    void SetStature(int x){stature=x;}  
private:
    int stature;
    int weight();
   
};

void main()
{
   human Mike;
   Mike.SetStature(8);
   Mike.get_stature();
}
#13
xxmmxmxm2013-09-11 19:41
class  human
{
public:

    void get_stature(){cout<<stature;}
    void GetWeight();
    void SetStature(int x){stature=x;}  
private:
    int stature();//变量名不用加()的,加了就是函数了
    int weight();
   
};
#14
IT男year2013-09-18 18:26
回复 7楼 超神级
亲,把你自己改的正确答案发表一下。
#15
magry2013-09-19 11:26
#include <iostream>
using namespace std;
class  human
{
public:

    void get_stature(){cout<<stature;}
    void GetWeight();
    void SetStature(int x){stature=x;}  
private:
    //下边两处多了括号
    int stature;
    int weight;
   
};

void main()
{
   human Mike;
   Mike.SetStature(8);
   Mike.get_stature();
}
#16
kaka_dylon2013-09-21 16:13
int stature()不要后面的小括号就对了
1