c++构造函数不能有返回类型错误提示?解决方法!
2014-02-19 17:35
495 查看
43 class Point 44 { 45 public: 46 Point(int xx, int yy){X = xx; Y = yy;}//构造该函数 47 Point(Point &p); 48 int GetX(void){return X;}//取X坐标 49 int GetY(void){return Y;}//取Y坐标 50 private: 51 int X, Y;//点的坐标 52 } 53 54 Point::Point(Point &p) 55 { 56 X = p.X; 57 Y = p.Y; 58 cout << "Point拷贝构造函数被调用"<<endl; 59 60 }
提示错误行号:54
编译时一直提示构造函数不能有返回类型?
原来是Point类的定义在52行没有加分号。
修改为以下代码
43 class Point 44 { 45 public: 46 Point(int xx, int yy){X = xx; Y = yy;}//构造该函数 47 Point(Point &p); 48 int GetX(void){return X;}//取X坐标 49 int GetY(void){return Y;}//取Y坐标 50 private: 51 int X, Y;//点的坐标 52 };
相关文章推荐
- C++编译错误:error C2533: 构造函数不能有返回类型
- c++解决 {ctor}构造函数不能有返回类型或者无故缺少“;”(在“using”的前面)的问题
- 关于文件不能访问,IIS提示MIME类型没有错误的解决方法
- C++编译出现 错误 1 error C2533: “TA::{ctor}”: 构造函数不能有返回类型
- 错误提示:不能在返回类型中定义新类型
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认int 错误的解决方法
- Access提示 429错误, ActiveX 部件不能创建对象的解决方法
- 不能将 "const char *" 类型的值分配到 "LPCWSTR" 类型的实体 错误解决方法
- hibernate中实体类构造方法中含有Timestamp 类型变量的"no appropriate constructor.." 错误提示的解决办法
- 错误不能将参数“**”转换为“LPCWSTR”的解决方法(C++)
- 解决安装ie8 后IE8提示应用程序错误 该内存不能为 read 解决方法
- 关于“构造函数不能有返回类型”的解决办法
- c++中调用python脚本提示 error LNK2001: 无法解析的外部符号 __imp_Py_Initialize等错误的解决方法
- IIS ADMIN不能启动,提示错误代码-2146893818的解决方法
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int"错误的解决方法
- error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int 错误的解决方法
- 构造函数不能有返回类型 ,函数定义或声明中有错误;未调用函数
- 1 IntelliSense: 不能将 "const char *" 类型的值分配到 "LPCWSTR" 类型的实体 错误解决方法
- sql sever 2005 replication 时对于 image,text类型的字段提示错误的解决方法
- MySQL服务不能启动,提示1067错误的解决方法