
C++
guozipi
这个作者很懒,什么都没留下…
展开
-
C++中的构造函数、拷贝构造函数、析构函数
1、构造函数constructor (1)构造函数的名字必须与类名相同; (2)创建对象时自动调用的,且仅执行一-次 ; (3)public ,无返回值,无需定义返回类型; (4)允许重载,可以定义多个 (5)尽量简单,太复杂、包含大量逻辑处理的 (6)初始化工作建议用单独的Init()方法实现 (7)避免对象创建时出错 this是一个指针 ,指向对象自己 2、默认构造函数 在没有定义任何构造函...原创 2018-08-15 10:32:50 · 200 阅读 · 0 评论 -
C++——对象数组
Coordinate.h #include "stdafx.h" #include <iostream> using namespace std; class Coordinate { public: Coordinate(); ~Coordinate(); int i_x; int i_y; }; Coordinate.cpp #include "stdaf...原创 2018-08-16 17:17:10 · 458 阅读 · 0 评论 -
对象成员学习
coor.h #pragma once #include "stdafx.cpp" #include <iostream> using namespace std; class Coordinate { public: Coordinate(int x, int y); ~Coordinate(); void setX(int _x); int getX(); vo...原创 2018-08-24 11:35:35 · 313 阅读 · 0 评论 -
浅拷贝与深拷贝的学习
Array.h #ifndef ARRAY_H #define ARRAY_H #include <iostream> using namespace std; class Array{ public: Array(int m_iCount); Array(const Array &arr); ~Array(); void setCount...原创 2018-08-22 16:21:40 · 161 阅读 · 0 评论 -
this指针学习
在Qt中写的代码,所以Array类自动变为小写。 array.h #ifndef ARRAY_H #define ARRAY_H class array { public: array(int len); ~array(); array *setLen(int len); int getlen(); array *printf(); private...原创 2018-08-23 16:31:41 · 115 阅读 · 0 评论 -
对象成员指针学习
coordinate.h #ifndef COORDINATE_H #define COORDINATE_H class coordinate { public: coordinate(int x, int y); ~coordinate(); int getX(); int getY(); private: int m_iX; int m...原创 2018-08-23 23:23:31 · 187 阅读 · 0 评论