啊哈磊_编程从这里起步
标题:
求大神帮忙看下这个程序哪里错了!
[打印本页]
作者:
超神级
时间:
2013-9-8 21:46
标题:
求大神帮忙看下这个程序哪里错了!
#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();
}
作者:
rosynirvana
时间:
2013-9-8 21:46
首先
int stature();
int weight();
这两个吧,你要的应该是
int stature, weight;
然后main的类型写成void也是错的,我不知道你的编译器会怎么处理,但是标准中要求main的返回类型必须是int
作者:
超神级
时间:
2013-9-9 08:54
本帖最后由 超神级 于 2013-9-9 09:01 编辑
rosynirvana 发表于 2013-9-9 01:22
首先
int stature();
报错了。。。!main前面换成int就好了!非常感谢!
作者:
北极风
时间:
2013-9-9 11:21
类---学习了。
欢迎光临 啊哈磊_编程从这里起步 (https://bbs.codeaha.com/)
Powered by Discuz! X3.2