error C2600: 'Point::Point' : cannot define a compiler-generated special member function (must be de
来源:互联网 发布:seo h1标签 编辑:程序博客网 时间:2024/05/18 15:04
1、运行程序时,出现这个error C2600: 'Point::Point' : cannot define a compiler-generated special member function (must be declared in the class first)错误,感觉没什么问题,仔细一看才发现,是我错了。
2、我以为,不带参数的构造函数可以不用声明就直接在类外定义,没想到也需要在类外定义。
错误代码如下:
2_2_1.h#ifndef _2_2_1_H_#define _2_2_1_H_class Point{private:int x;int y;public:void output();};#endif2_2_1.cpp#include"iostream.h"#include"2_2_1.h"void Point::output(){cout<<"x:"<<x<<" y:"<<y<<endl;}void Point::Initial(){x = 5 ;y = 7 ;}Point::Point(){x = 6;y = 6;}void main(){Point pt;pt.output();//构造函数的效果和Initial函数的效果是一样的pt.Initial();//类似于自己买零件,再用自己买的零件组装电脑。pt.output();//输出5和7}正确代码如下:
2_2_1.h#ifndef _2_2_1_H_#define _2_2_1_H_class Point{private:int x;int y;public:void output();Point();<span style="white-space:pre"></span>//错误代码就少了这一句};#endif2_2_1.cpp#include"iostream.h"#include"2_2_1.h"void Point::output(){cout<<"x:"<<x<<" y:"<<y<<endl;}void Point::Initial(){x = 5 ;y = 7 ;}Point::Point(){x = 6;y = 6;}void main(){Point pt;pt.output();//构造函数的效果和Initial函数的效果是一样的pt.Initial();//类似于自己买零件,再用自己买的零件组装电脑。pt.output();//输出5和7}
0 0
- error C2600: 'Point::Point' : cannot define a compiler-generated special member function (must be de
- LINK : fatal error LNK1561: entry point must be defined
- LINK : fatal error LNK1561: entry point must be defined
- ErrorLNK1561:entry point must be defined
- VC++ 常见调试错误:fatal error LNK1561: entry point must be defined
- VC++ 常见调试错误:fatal error LNK1561: entry point must be defined
- 编译错误 fatal error LNK1561: entry point must be defined
- VC++ 常见调试错误:fatal error LNK1561: entry point must be defined
- VC++ 常见调试错误:fatal error LNK1561: entry point must be defined
- [C++]C++重载 opeartor= must be a nonstatic member function?
- 'operator =' must be a <Unknown> member
- error: a host function call cannot be configured CUDA Linux
- Can a member function template be virtual?
- reference to non-static member function must be called
- while u 定义 a point,u must 初始化it
- Point
- Point
- point
- 题目1518:反转链表
- NOPI使用手册
- android 设置全屏
- 如何使用hadoop实现精准营销
- 拓扑排序
- error C2600: 'Point::Point' : cannot define a compiler-generated special member function (must be de
- 循环链表-约瑟夫环(程序员面试宝典修正代码)
- Git详解
- 问题:关于坛友的一个js轮播效果的实现
- Spark 阅读资料汇总
- 计算机系统要素:第八章 虚拟机II 程序控制
- jsp spring 技术(一)
- ERROR 1130: Host '192.168.1.3' is not allowed to connect to this MySQL
- C++中计算程序的运行时间