程序小问题

shabimnhjk 2008-03-03 09:37:10
#include<stdio.h>
#include<windows.h>
#include<string.h>
void gotoxy(int x,int y)
{
COORD c;
c.X=x-1;
c.Y=y-1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE),c);
}
class point{
int x,y;
public:
point(int vx,int vy)
{
x=vx;
y=vy;
}
int getx()
{
return x;
}
int gety()
{
return y;
}
};
class string{
int length;
char *contents;
public:
string(char *s)
{
length=strlen(s);
contents=new char[length+1];
strcpy(contents,s);
}
void show(int x,int y)
{
gotoxy(x,y);
printf("%s\n",contents);
}
};
class outer_class{
point p1;
string 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)
//'outer_class::outer_class' : constructors not allowed a return type
{}
main()
{
char *s="The string object";
outer_class object(20,10,s);
//'outer_class::outer_class' : error in function definition or declaration; function not called object.show();
return 1;
}
...全文
43 3 打赏 收藏 举报
写回复
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
天亮后说晚安 2008-03-04
  • 打赏
  • 举报
回复
飘过
liyuzhu_1984 2008-03-03
  • 打赏
  • 举报
回复
goto 1楼
cmail 2008-03-03
  • 打赏
  • 举报
回复
class outer_class{
point p1;
string s1;
public:
outer_class(int x,int y,char *s);
void show()
{
s1.show(p1.getx(),p1.gety());
}
}
掉了个分号。
发帖
C++ 语言

6.3w+

社区成员

C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
帖子事件
创建了帖子
2008-03-03 09:37
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下