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

2016年6月27日

C++ 运算符重载一(二元运算符重载)

摘要: //二元运算符重载 #include using namespace std; class Point { public: Point(int x,int y){ this->x = x; this->y = y; } //为什么要使用友元函数呢 friend Point operator+(Point &p1, Point &p... 阅读全文

posted @ 2016-06-27 10:26 寒魔影 阅读(1416) 评论(0) 推荐(0)

2016年6月24日

C++ 友元类,友元函数

摘要: //友元函数 友元类 #include using namespace std; class PointB { public: friend class PointC; //类PointC是类PointB的友元类--意味着类PointC对象可以调用PointB中所有的成员 void Test(){ ; } private: int ... 阅读全文

posted @ 2016-06-24 09:59 寒魔影 阅读(212) 评论(0) 推荐(0)

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

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

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

posted @ 2016-06-23 11:34 寒魔影 阅读(611) 评论(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 寒魔影 阅读(357) 评论(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 寒魔影 阅读(1565) 评论(0) 推荐(0)

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

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

posted @ 2016-06-22 18:01 寒魔影 阅读(912) 评论(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)

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

导航