上一页 1 ··· 44 45 46 47 48 49 50 51 52 ··· 59 下一页

2016年6月23日

C++ 类的对象管理模型初讲

摘要: //类的对象管理模型初讲 #include using namespace std; class PointA{ private: int x;//占据4个字节大小的内存空间 int y;//占据4个字节大小的内存空间 int z;//占据4个字节大小的内存空间 };//总共占据12个字节 class PointB{ public: PointB(int _... 阅读全文

posted @ 2016-06-23 13:51 寒魔影 阅读(509) 评论(0) 推荐(0) 编辑

C++ 类中的静态成员变量,静态成员函数

摘要: //类中的静态成员变量,静态成员函数 #define _CRT_SECURE_NO_WARNINGS #include using namespace std; /* 静态成员函数是属于整个类, static修饰的变量,是属于类,,所有的对象都能共享用。 在类的静态数据成员函数中,是不能调用具体的对象的变量的属性, 这是因为static修饰的变量是整个类共享,在静态成员函数中使用一个对象的成员... 阅读全文

posted @ 2016-06-23 11:34 寒魔影 阅读(553) 评论(0) 推荐(0) 编辑

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 寒魔影 阅读(337) 评论(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 寒魔影 阅读(192) 评论(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 寒魔影 阅读(1530) 评论(0) 推荐(0) 编辑

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

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

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

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

摘要: 构造函数和析构函数调用顺序总结: 构造函数与析构函数的调用顺序 当类中有成员变量是其它类的对象时 首先调用成员变量的构造函数 调用顺序与声明顺序相同 之后调用自身类的构造函数 析构函数的调用顺序与对应的构造函数调用顺序相反 阅读全文

posted @ 2016-06-22 17:36 寒魔影 阅读(528) 评论(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 寒魔影 阅读(7839) 评论(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 寒魔影 阅读(1450) 评论(0) 推荐(0) 编辑

2016年6月21日

C++ 构造函数与析构函数

摘要: //构造函数--析构函数 #include using namespace std; class Point{ public: /*无参构造函数*/ Point(){ x = 0; y = 1; cout << "无参构造函数被执行了.." << endl; } /*有参构造函数*/ Point(int _x... 阅读全文

posted @ 2016-06-21 17:46 寒魔影 阅读(191) 评论(0) 推荐(0) 编辑

上一页 1 ··· 44 45 46 47 48 49 50 51 52 ··· 59 下一页

导航