上一页 1 ··· 4 5 6 7 8 9 10 下一页
摘要: 如果构造函数只接受一个实参,则它实际上定义了转换为此类类型的隐式转换机制。将这种构造函数称为转换构造函数。#ifndef MAIN_H_INCLUDED#define MAIN_H_INCLUDED#includeusingnamespace std;classClassTest{public:Cl... 阅读全文
posted @ 2015-07-16 19:17 指上弹兵赵小括 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 当在类外部定义静态成员时,不能重复使用static关键字静态成员函数不包含this指针(无论是显示还是隐式使用)静态成员可以通过类对象进行访问,也可以通过类进行访问静态成员不是由构造函数初始化的,一般来说不能在类的内部初始化静态成员静态数据成员定义在任何函数之外,且只能被定义一次在定义静态数据成员时... 阅读全文
posted @ 2015-07-16 19:15 指上弹兵赵小括 阅读(330) 评论(0) 推荐(0) 编辑
摘要: 基本特性const对象一旦创建后其值就不能被修改,故而const对象必须进行初始化可以用一个非const对象初始化一个const对象,也可以用一个const对象赋值给一个非const对象默认状态下,const对象仅在文件内有效当多个文件内出现了同名的const变量时,等同于在不同文件中定义了独立的变... 阅读全文
posted @ 2015-07-16 19:14 指上弹兵赵小括 阅读(273) 评论(0) 推荐(0) 编辑
摘要: #includeusingnamespace std;class BASE{public: BASE()=default; BASE(int publicValue,int protectedVale,int privateValue){this->publicValue = publicValue... 阅读全文
posted @ 2015-07-16 19:13 指上弹兵赵小括 阅读(2282) 评论(0) 推荐(0) 编辑
摘要: #includeusingnamespace std;class MYCLASS{public: MYCLASS()=default;/*explicit*/ MYCLASS(string str): strValue(str){ cout intValue = myClass.intValue;t... 阅读全文
posted @ 2015-07-16 19:12 指上弹兵赵小括 阅读(403) 评论(0) 推荐(0) 编辑
摘要: C++的static有两种用法:面向过程程序设计中的static和面向对象程序设计中的static。前者应用于普通变量和函数,不涉及类;后者主要说明static在类中的作用。1.面向过程设计中的static1.1静态全局变量全局变量(外部变量)的说明之前再冠以static 就构成了静态的全局变量。全... 阅读全文
posted @ 2015-07-16 19:11 指上弹兵赵小括 阅读(235) 评论(0) 推荐(0) 编辑
摘要: #include#includeusingnamespace std;/**::iterator uniqueElements(vector::iterator begPos,vector::iterator endPos){auto currPos = begPos +1;while(currPo... 阅读全文
posted @ 2015-07-16 19:10 指上弹兵赵小括 阅读(336) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#includeusingnamespace std;templatevoidPrintElements(T c){typename T::const_iterator itr = c.begin();//在GCC下typename不能省略while(... 阅读全文
posted @ 2015-07-16 19:08 指上弹兵赵小括 阅读(575) 评论(0) 推荐(0) 编辑
摘要: 来自为知笔记(Wiz) 阅读全文
posted @ 2015-07-16 19:07 指上弹兵赵小括 阅读(195) 评论(0) 推荐(0) 编辑
摘要: auto自动类型推断,用于从初始表达式中推断出变量的类型。auto a;// 错误,没有初始化表达式,无法推断出a的类型autoint a =10;// 错误,auto临时变量的语义在C++ 11中已不存在auto a =10;auto c ='A';auto s("hello");vector v... 阅读全文
posted @ 2015-07-16 19:05 指上弹兵赵小括 阅读(796) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8 9 10 下一页