上一页 1 ··· 45 46 47 48 49 50 51 52 53 ··· 60 下一页

2016年6月23日

C++ 类的抽象初练

摘要: /* 某商店经销一种货物,货物的购进和卖出以箱为单位,各箱的重量不一样, 因此商店需要目前库存的总重量。 现在用c++模拟商店货物购进和卖出的情况 */ #include using namespace std; //货物类 class Goods{ public: Goods(int w=0){ this->weight = w; } int G... 阅读全文

posted @ 2016-06-23 23:18 寒魔影 阅读(324) 评论(0) 推荐(0)

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 寒魔影 阅读(526) 评论(0) 推荐(0)

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

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

posted @ 2016-06-23 11:34 寒魔影 阅读(607) 评论(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 寒魔影 阅读(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)

上一页 1 ··· 45 46 47 48 49 50 51 52 53 ··· 60 下一页

导航