Fork me on GitHub
摘要: 程序示例 1 #include 2 using namespace std; 3 class a 4 { 5 public: 6 a(){cout<<"构造a"<<endl;} 7 ~a(){cout<<"析构a"<<endl;} 8 }; 9 class b10 {11 publ... 阅读全文
posted @ 2015-08-10 22:21 夏成都 阅读(373) 评论(0) 推荐(0) 编辑
摘要: 代码如下 1 //抽象数据类型线性表的定义 2 #include 3 /*-------------------初始化线性表-----------------------*/ 4 void InitList(SqList *&L) 5 { 6 L=(SqList*)malloc(sizeo... 阅读全文
posted @ 2015-08-10 21:13 夏成都 阅读(861) 评论(0) 推荐(1) 编辑
摘要: 单一继承:一个父类,可以有多个子类多重继承:多个父类,只有一个子类程序示例 //多重继承 1 #include 2 using namespace std; 3 class father//父类一 4 { 5 public: 6 void set_father(int a){ tal... 阅读全文
posted @ 2015-08-07 09:21 夏成都 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 什么是容器首先,我们必须理解一下什么是容器,在C++ 中容器被定义为:在数据存储上,有一种对象类型,它可以持有其它对象或指向其它对像的指针,这种对象类型就叫做容器。很简单,容器就是保存其它对象的对象,当然这是一个朴素的理解,这种“对象”还包含了一系列处理“其它对象”的方法,因为这些方法在程序的设计上... 阅读全文
posted @ 2015-08-06 17:09 夏成都 阅读(183) 评论(0) 推荐(0) 编辑
摘要: 代码示例 1 #include 2 using namespace std; 3 class A 4 { 5 public: 6 A(int x){ i = x; cout << "构造函数执行!" << i << endl; }//可以关键字explicit用来禁止隐式转换,然而显式转换... 阅读全文
posted @ 2015-08-05 17:30 夏成都 阅读(351) 评论(0) 推荐(0) 编辑
摘要: 示例代码 1 #include 2 using namespace std; 3 class A 4 { 5 public: 6 A(){cout 2 using namespace std; 3 class A 4 { 5 public: 6 A(int a, i... 阅读全文
posted @ 2015-08-03 16:13 夏成都 阅读(334) 评论(0) 推荐(0) 编辑
摘要: 程序示例 1 #include 2 using namespace std; 3 class rectange 4 { 5 public: 6 rectange() :length(3), width(5){ cout << "长方形的面积为:" << length*width << end... 阅读全文
posted @ 2015-08-02 21:31 夏成都 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 代码示例 1 #include 2 using namespace std; 3 class A 4 { 5 public: 6 void set(int = 30, int = 5);//声明函数时,初始化参数 7 void count(bool = false);//声明函数时... 阅读全文
posted @ 2015-08-02 16:02 夏成都 阅读(329) 评论(0) 推荐(0) 编辑
摘要: 程序示例 1 #include 2 using namespace std; 3 class A 4 { 5 public: 6 A(); 7 ~A(); 8 int get() const{ return *i; } 9 void set(int x){ *i =... 阅读全文
posted @ 2015-08-01 15:23 夏成都 阅读(205) 评论(0) 推荐(0) 编辑
摘要: 演示程序 1 #include 2 using namespace std; 3 class A 4 { 5 public: 6 A(){cout执行构造函数创建一个对象17 func(a);//跳转到函数定义处,执行两次复制构造函数-->第一次,传递参数,第二次,返回参数18 ... 阅读全文
posted @ 2015-08-01 15:16 夏成都 阅读(317) 评论(0) 推荐(0) 编辑