找出错误原因

zhouhaoIT2005 2007-07-09 10:56:42
class point{
int x,y;
public:
point(int vx,int vy){x = vx; y = vy;}
int getx(){return x;}
int gety(){return y;}
};
class str{
int length;
char *contents;
public:
str(char *s)
{
length = strlen(s);
contents = new char[length + 1];
strcpy(contents,s);
}
void show(int x,int y)
{
goto(x,y);//提示[C++ Error] Unit1.cpp(29): E2271 Goto statement missing label
printf("%s\n",contents);
}
};
class outer_class{
point p1;
str s1;
public:
outer_class(int x,int y,char *s);
void show()
{s1.show(p1.getx(),p1.gety()); }
};
outer_class::outer_class(int x,int y,char *s):p1(x,y),s1(s)
{}

int main(int argc, char* argv[])
{
char *s = "the string object";
outer_class object(230,100,s);
object.show();
cin.get();
请问是怎么回事??以前很少用goto,所以想请高手指点.谢谢
...全文
81 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
i_love_pc 2007-07-09
  • 打赏
  • 举报
回复
使用gotoxy()



Header File

conio.h

Category

Console I/O Routines

Prototype

void gotoxy(int x, int y);

Description

Positions cursor in text window.

gotoxy moves the cursor to the given position in the current text window. If the coordinates are in any way invalid the call to gotoxy is ignored. An example of this is a call to gotoxy(40,30) when (35,25) is the bottom right position in the window. Neither argument to gotoxy can be zero.

Note: Do not use this function in Win32 GUI applications.

Return Value

None.
cczlp 2007-07-09
  • 打赏
  • 举报
回复
goto 是关键字, 不是函数

13,825

社区成员

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

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