2016年6月22日

C++ new delete操作符

摘要: //new delete操作符 #define _CRT_SECURE_NO_WARNINGS #include using namespace std; /* 1.new delete 操作符号 都是 c++的关键字 类似于 C语言中的 malloc()函数 free()函数 2.定义对象时,使用了new关键字,会为这个对象在堆上分配内存,不使用new 关键字会直接在栈上分配内存 n... 阅读全文

posted @ 2016-06-22 22:39 寒魔影 阅读(352) 评论(0) 推荐(0)

C++ 构造中调用构造

摘要: //构造中调用构造 #define _CRT_SECURE_NO_WARNINGS #include using namespace std; class Point{ public: Point(int _x,int _y,int _z){ cout << "自定义的有参构造函数被调用了1" << endl; x = _x; y = _... 阅读全文

posted @ 2016-06-22 21:41 寒魔影 阅读(207) 评论(0) 推荐(0)

C++ 匿名对象的生命周期

摘要: //匿名对象的生命周期 #define _CRT_SECURE_NO_WARNINGS #include using namespace std; class Point{ public: Point(){ cout << "自定义的无参构造函数被调用了1" << endl; } ~Point(){ cout << "自定义的析构函数被调... 阅读全文

posted @ 2016-06-22 21:30 寒魔影 阅读(1561) 评论(0) 推荐(0)

C++ 构造函数的对象初始化列表

摘要: 初始化列表,数组初始化 阅读全文

posted @ 2016-06-22 18:01 寒魔影 阅读(798) 评论(0) 推荐(0)

C++ 类的构造函数使用规则

摘要: //类的构造函数使用规则 #define _CRT_SECURE_NO_WARNINGS #include<iostream> using namespace std; class PointA{ }; class PointB{ public: PointB(int _a, int _b, con 阅读全文

posted @ 2016-06-22 17:36 寒魔影 阅读(541) 评论(0) 推荐(0)

C++ 类的深拷贝和浅拷贝完美解决

摘要: //类的深拷贝和浅拷贝 #define _CRT_SECURE_NO_WARNINGS #include using namespace std; class Point{ public: Point(int _a,int _b,const char *pin/*in*/){ x = _a; y = _b; remark = (char ... 阅读全文

posted @ 2016-06-22 17:06 寒魔影 阅读(7887) 评论(0) 推荐(0)

C++ 匿名对象初始化新对象

摘要: //c++中匿名对象初始化新对象 #include using namespace std; class Point{ public: Point(){ cout << "我是自定义的无参构造函数1" << endl; } Point(Point &pm){ cout << "我是自定义的拷贝构造函数3" << endl; } ... 阅读全文

posted @ 2016-06-22 16:26 寒魔影 阅读(1505) 评论(0) 推荐(0)

导航