上一页 1 2 3 4 5 6 7 8 ··· 11 下一页

2018年7月1日

摘要: 1 //public继承特点:基类中公有成员和保护成员将分别作为派生类的公有成员和保护成员 2 //private继承特点:基类中公有成员和保护成员将分别作为派生类的私有成员 3 //protected继承特点:基类中公有成员和保护成员将分别作为派生类的保护成员 4 //下面是public继承举例 5 #include 6 class A{ 7 private: ... 阅读全文
posted @ 2018-07-01 12:44 孙悟空son_ku_kong 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 1 //字符串类的设计 2 //1.字符串类String能与C语言的字符串兼容使用 3 //2.重载逻辑等于运算符(==) 4 //3.字符串操作包括取字符串长度和取子串 5 #include 6 #include 7 #include 8 class String{ 9 private: 10 char *str; 11 ... 阅读全文
posted @ 2018-07-01 12:16 孙悟空son_ku_kong 阅读(150) 评论(0) 推荐(0) 编辑

2018年6月29日

摘要: 1 //设计一个double类型的数组Array 2 //1.可定义下界下标和上届上标 3 //2.可对下标越界进行检查 4 //3.可重置数组大小 5 //4.可知道数组的长度 6 //5.数组类的对象可以使用赋值运算符=和下标运算符[] 7 8 #include 9 #include 10 class Array{ 11 privat... 阅读全文
posted @ 2018-06-29 19:11 孙悟空son_ku_kong 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 1 //设计运算符重载的复数类 2 #include 3 4 class Complex{ 5 private: 6 double real;//实部 7 double image;//虚部 8 public: 9 Complex(){ 10 real=0; 11 ... 阅读全文
posted @ 2018-06-29 19:09 孙悟空son_ku_kong 阅读(128) 评论(0) 推荐(0) 编辑
摘要: 1 //设计运算符重载的复数类 2 #include 3 4 class Complex{ 5 private: 6 double real;//实部 7 double image;//虚部 8 public: 9 Complex(){ 10 real=0; 11 ... 阅读全文
posted @ 2018-06-29 19:08 孙悟空son_ku_kong 阅读(135) 评论(0) 推荐(0) 编辑
摘要: 1 //友元分为友元类和友元成员函数和友元函数 2 //设计A类是B类的友元类 3 //那么A类可以访问B类的所有成员(公有、私有、保护成员),同理,友元类和友元函数也是一样 4 #include 5 class B{ 6 friend class A; 7 private: 8 int topSecret; 9 public: 10 ... 阅读全文
posted @ 2018-06-29 19:05 孙悟空son_ku_kong 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 1 //static成员的学习 2 #include 3 #include 4 5 class Employee{ 6 private: 7 char name[30]; 8 float salary; 9 static float allSalary; 10 public: 11 Employe... 阅读全文
posted @ 2018-06-29 18:51 孙悟空son_ku_kong 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 1 //内部类的学习 2 #include 3 class Line{ 4 class Point{ 5 public: 6 int x; 7 int y; 8 Point(int x=0,int y=0){ 9 this->x=x; 10 ... 阅读全文
posted @ 2018-06-29 18:50 孙悟空son_ku_kong 阅读(130) 评论(0) 推荐(0) 编辑
摘要: 1 //析构函数的学习 2 #include 3 class Point{ 4 private: 5 int x; 6 int y; 7 public: 8 Point(){} 9 Point(int x,int y){ 10 this->x=x; 11 ... 阅读全文
posted @ 2018-06-29 18:49 孙悟空son_ku_kong 阅读(110) 评论(0) 推荐(0) 编辑
摘要: 1 //设计一个线段类 2 #include 3 class Point{ 4 private: 5 int x; 6 int y; 7 public: 8 Point(){} 9 Point(int x,int y){ 10 this->x=x; 11 ... 阅读全文
posted @ 2018-06-29 18:36 孙悟空son_ku_kong 阅读(140) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 ··· 11 下一页

导航