今天用VC6编程时,出现错误:
error C2533: 'WumpusWorld::WumpusWorld' : constructors not allowed a return type
程序并没有返回值,构造函数嘛,
上网一查,方有一位仁兄和我同样境遇,原来是
头文件中类声明的时候,没有在类结尾加上";"

这个错误提示定位也太风马牛不相及了.

posted on 2007-01-09 23:21 哈哈 阅读(6013) 评论(19)  编辑 收藏 引用

评论:
# re: 编译错误:constructors not allowed a return type 2007-01-10 11:32 | 傅衍杰your roommate
我也尝试过这样的错误,可是我那次反而正确定位在那里哦  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2007-01-10 11:56 | 平凡小草
用assistx啊,可以避免这样的输入语法错误  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2007-01-11 09:15 | sogno
微软的c++编译器这块做得确实不怎么样,错误提示驴唇不对马嘴,比gcc差远了  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2007-01-11 15:00 | 空明流转
一点都不是问题。

编译器认为你的定义是

你一定是这样的结构
//header

class XXX{
}

//source

#nclude "xxx.h"
XXX::XXX()
{
}
//....

编译器会解释为
class XXX{} XXX::XXX()
{
}

并非风马牛不相及。

所以不要随便就责怪编译器。  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2007-01-11 16:17 | pengkuny
@空明流转
老大说得是  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2007-04-03 18:16 | 王一伟
呵呵 研究下编译原理 还是很有裨益 :)  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2008-04-15 15:07 | Mashka
没有分号  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2008-04-15 17:20 | 小子
晕死
  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2008-04-15 17:22 | 小子
#include<iostream>
using namespace std;
class juzhen
{
public:juzhen(int l,int k);
~juzhen(){delete p;};
void out();

private:
int i,j,*p;
}//就是这里少了个;!!!!!!!!!!!!!!!!!!!!!//
juzhen::juzhen(int l,int k)
{
i=l,j=k;
int i1,j1;
p=new int(i*j);
for(i1=0;i1<i;i1++)
for(j1=0;j1<j;j1++)
cin>>*(p+i1*j+j1);
}
void juzhen::out()
{
int i1,j1;
for(i1=0;i1<i;i1++)
for(j1=0;j1<j;j1++)
cout<<*(p+i1*j+j1);
}

void main()
{
int x,y;
cout<<"请输入x,y"<<endl;
cin>>x>>y;
juzhen d(x,y);
d.out();
}  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2008-10-31 11:29 | 安安
呵呵。我也碰到了这个问题,百度下就百度到老兄你了。。谢啦  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2008-10-31 22:42 | xj
同楼上~  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2009-03-05 15:36 | hui
我也遇到了这个问题,google一下就找到兄弟你了,问题一下子就解决掉,谢谢,呵呵  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type[未登录] 2009-03-20 14:24 | Leo
同感  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2009-07-23 17:34 | aa
彼此彼此  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2009-07-30 19:47 | haizhifeng
高手呀,真是太感谢了!!!!  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2009-10-12 14:47 | huang
谢谢了,很有用呵呵  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2009-12-25 10:25 | clouds
谢谢阿。我也是google过来的。  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2010-04-09 18:19 | 写什么姓名吗?
同样遇到这个问题,看到答案后一分析,果然这个提示有些道理啊,呵呵  回复  更多评论
  
# re: 编译错误:constructors not allowed a return type 2010-07-30 10:36 | wo
@写什么姓名吗?
我也遇到了这个错误。结果google一下就到这里了  回复  更多评论
  

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理