这样的错误 local class member functions must be defined within the class

okop 2003-09-14 09:55:41

这样的错误 local class member functions must be defined within the class这样的程序
#include<iostream.h>

void main(void)
{
class man
{
public:
void setx(int x);
void sety(int y);
int result(void);
private:
int r;
int h;

};
void man::setx(int x)
{
r=x;
}
void man::sety(int y)
{
h=y;
}
int man::result(void)
{
return r*h;
}
man objman;
objman.setx(10);
objman.sety(10);
cout<<objman.result();

}
...全文
105 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
chenpeng20000 2003-09-15
  • 打赏
  • 举报
回复
只把
man objman;
objman.setx(10);
objman.sety(10);
cout<<objman.result();
放在main()里面
cizi 2003-09-15
  • 打赏
  • 举报
回复
关于类的一切放在Main()的外面
fathappy 2003-09-15
  • 打赏
  • 举报
回复
好好看看你的程序吧,类的定义,成员函数的定义声明,都应放在主函数的外面。

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧