01_函数模板定义.cpp#include#include using namespace std;#if 0int MAX(int a,int b){ coutb?a:b;}char MAX(char a,char b){ coutb?a:b;}double MAX... Read More
posted @ 2016-03-30 19:18 夜色下的港湾 Views(136) Comments(0) Diggs(0)
01_多继承定义.cpp#includeusing namespace std;//父类先构造,子类先析构struct GrandFather{ int pound=2000000; GrandFather(){ coutusing namespace s... Read More
posted @ 2016-03-30 19:15 夜色下的港湾 Views(186) Comments(0) Diggs(0)
01_单继承语法.cpp#includeusing namespace std;//继承就是使得一个类可以拥有另一个类的成员数据和方法的一种快速语法形式//语法://class/struct [子类名]:[父类名]// [派生类]:[基类]struct Fa... Read More
posted @ 2016-03-30 18:50 夜色下的港湾 Views(311) Comments(0) Diggs(0)
1C++_类成员变量指针.cpp#includeusing namespace std;struct A{ int m=10; int n=9;};//类的成员变量指针,只能指向该类的成员变量,不会超出范围,这样做可以减小程序员纠错的范围,提高代码的维护性int mai... Read More
posted @ 2016-03-30 14:05 夜色下的港湾 Views(458) Comments(0) Diggs(0)
1c++_union.cpp#includeusing namespace std;//union是联合体,其所在空间是其内部最大元素的空间大小 ,换句话说,其内部所有成员的空间是共用的union A{ int a=0x30313233; char s[4];};int... Read More
posted @ 2016-03-30 14:03 夜色下的港湾 Views(110) Comments(0) Diggs(0)
1_枚举类.cpp#include//枚举类是带有类类型特征的枚举类型using namespace std;enum class COLOR {RED,BLUE,GREEN}; //default: RED=0; BLUE=RED+1;...class Book_b... Read More
posted @ 2016-03-30 14:02 夜色下的港湾 Views(112) Comments(0) Diggs(0)
1 constexpr类.cpp#includeusing namespace std;//constexpr 类是指该类的构造函数被constexpr修饰后,其传递的参数不能是变量,只能是常量(只读变量,字面值)class A{ int a,b; public: ... Read More
posted @ 2016-03-30 14:02 夜色下的港湾 Views(375) Comments(0) Diggs(0)
1_聚合类.cpp#includeusing namespace std;//如果一个类只定义成员变量,而没有定义成员函数,那么该类被称作聚合类struct student{ int id; string name; int age;};int main(){} ... Read More
posted @ 2016-03-30 14:01 夜色下的港湾 Views(237) Comments(0) Diggs(0)
01_局部类.cpp#includeusing namespace std;//局部类是指在一个函数内部定义的类int get(){ int m=100; class A{ public: A(){/*cout<<m<<endl;*/} ... Read More
posted @ 2016-03-30 14:00 夜色下的港湾 Views(181) Comments(0) Diggs(0)
01_内部类.cpp#includeusing namespace std;//内部类是指在一个类内部定义的类//内部类本质就一个类,但是因其它在另一个类内部定义的,所以它可以访问外部类的成员class A{ class Inner{ public: ... Read More
posted @ 2016-03-30 13:59 夜色下的港湾 Views(163) Comments(0) Diggs(0)
1移动赋值运算符.cpp#include#includeusing namespace std;class my_string{ char* p=nullptr; public: my_string(){} my_string(const char* s){... Read More
posted @ 2016-03-30 13:57 夜色下的港湾 Views(380) Comments(0) Diggs(0)
1 c++ 移动构造函数.cpp#include#includeusing namespace std;class my_string{ char* p=nullptr; public: my_string(){} my_string(const char*... Read More
posted @ 2016-03-30 13:56 夜色下的港湾 Views(223) Comments(0) Diggs(0)
#includeusing namespace std;int main(){ //左值: int a=10; int b=9; //右值: /* a+b,add(a,b),1000,'a',"123"; */ //左值引用... Read More
posted @ 2016-03-30 13:55 夜色下的港湾 Views(111) Comments(0) Diggs(0)
#includeusing namespace std;class auto_pint{ class node{ public: int ref_count=0; int number=0; }; node * p =nu... Read More
posted @ 2016-03-30 13:53 夜色下的港湾 Views(183) Comments(0) Diggs(0)
01_lambda表达式.cpp#include#includeusing namespace std;class Func_call{ public:// Func_call(){coutbool 尾置返回类型 //{} 执行体 ... Read More
posted @ 2016-03-30 13:52 夜色下的港湾 Views(154) Comments(0) Diggs(0)
01_重载函数调用运算符.cpp#includeusing namespace std;class Func_call{ public: Func_call(){coutb; }};int main(){ Func_call fc /*()*/;//具名对象... Read More
posted @ 2016-03-30 13:51 夜色下的港湾 Views(217) Comments(0) Diggs(0)
1重载类型转换运算符.cpp#includeusing namespace std;class A{ public: int m=0; A()=default; A(int k){m=k;} ~A(){} operator int() { ... Read More
posted @ 2016-03-30 13:49 夜色下的港湾 Views(137) Comments(0) Diggs(0)
1 C++ 重载解引用_迭代器.cpp#include#includeusing namespace std;//实现迭代器的目的是可以进行泛型计算,比如使用范围for语句等等;//实现迭代器的步骤://1,定义一个内部类iterator//2,重载该内部类的!=, ++, */... Read More
posted @ 2016-03-30 13:48 夜色下的港湾 Views(988) Comments(0) Diggs(0)
#include#include#includeusing namespace std;class dynamic_int_array{ int * p=nullptr; int size =0; int capacity=0; public: dyn... Read More
posted @ 2016-03-30 13:47 夜色下的港湾 Views(269) Comments(0) Diggs(0)
1 赋值运算符重载.cpp#include#includeusing namespace std;class my_string{ char* p=nullptr; public: my_string(){} my_string(const char* s)... Read More
posted @ 2016-03-30 13:45 夜色下的港湾 Views(138) Comments(0) Diggs(0)
1 中括号重载.cpp#include#includeusing namespace std;class my_string{ char* p=nullptr; public: my_string(){} my_string(const char* s){ ... Read More
posted @ 2016-03-30 13:43 夜色下的港湾 Views(1562) Comments(0) Diggs(0)
1 C++ 重载输出符号.cpp#includeusing namespace std; struct Date{ int year,month,day; Date()=default; Date(int y,int m, int d) :year(... Read More
posted @ 2016-03-30 13:41 夜色下的港湾 Views(356) Comments(0) Diggs(0)
1 单目运算#includeusing namespace std;//复数class Complex{ public: double real,image; Complex()=default; Complex(double r, double i) ... Read More
posted @ 2016-03-30 13:39 夜色下的港湾 Views(298) Comments(0) Diggs(0)
#includeusing namespace std;int add(int a, int b){ return a+b;}int main(){ string s1 ="abc"; string s2 ="def"; string s3 = s1 + s... Read More
posted @ 2016-03-30 13:36 夜色下的港湾 Views(126) Comments(0) Diggs(0)
1成员函数重载#include#includeusing namespace std;class Cycle;class Point{ double x,y; public: Point()=default; Point(double rx ,double ... Read More
posted @ 2016-03-30 13:35 夜色下的港湾 Views(160) Comments(0) Diggs(0)
01_point.cpp #include#includeusing namespace std;class Point{ double x,y; public: Point()=default; Point(double rx ,double ry) ... Read More
posted @ 2016-03-30 13:32 夜色下的港湾 Views(142) Comments(0) Diggs(0)
01 _static.cpp#includeusing namespace std;struct student{ int id; string name;static string school; student()=default; student(i... Read More
posted @ 2016-03-30 13:29 夜色下的港湾 Views(255) Comments(0) Diggs(0)
01_const_class.cpp#includeusing namespace std;struct A{ int m; int n; A(){} A(int a,int b){m=a;n=b;} ~A(){}};int main(){ co... Read More
posted @ 2016-03-30 10:54 夜色下的港湾 Views(197) Comments(0) Diggs(0)
1_student_link_list.cpp#includeusing namespace std;struct student{ int id;string name;int age; student()=default; student(int i,stri... Read More
posted @ 2016-03-30 10:52 夜色下的港湾 Views(243) Comments(0) Diggs(0)
01_初始化参数列表.cpp#include#include #include using namespace std;struct Student{ int id=1001;//成员变量或对象 char *name=nullptr; int age=20; ... Read More
posted @ 2016-03-30 10:48 夜色下的港湾 Views(311) Comments(0) Diggs(0)
01_拷贝构造定义#include#include #include using namespace std;struct Student{ int id=1001;//成员变量或对象 char *name=nullptr; int age=20; int ... Read More
posted @ 2016-03-30 10:45 夜色下的港湾 Views(186) Comments(0) Diggs(0)
01_对象和malloc#include#include #include using namespace std;struct book_bag{ int color; int book_sum; book_bag(){ coutid =1001;... Read More
posted @ 2016-03-30 10:41 夜色下的港湾 Views(95) Comments(0) Diggs(0)
1析构函数.#include#include #include using namespace std;struct Student{ int id=1001;//成员变量或对象 char *name=nullptr; int age=20; int sco... Read More
posted @ 2016-03-30 10:39 夜色下的港湾 Views(197) Comments(0) Diggs(0)
1 C++成员变量初始化#include#include using namespace std;struct Student{ int id=1001; //成员变量或对象 char name[64]="zhangsan"; int age... Read More
posted @ 2016-03-30 10:36 夜色下的港湾 Views(120) Comments(0) Diggs(0)
#include#include using namespace std;struct student{ int id; //成员变量或对象 char name[64]; int age; int score; //...};typed... Read More
posted @ 2016-03-30 10:31 夜色下的港湾 Views(168) Comments(0) Diggs(0)
#includeusing namespace std;//constexpr 是更严格的定义只读变量,其要求该变量的初始化值必须是字面值常数(在未来版本可能扩展为也可以用其他只读变量初始化)int main(){ const int a =10; const int ... Read More
posted @ 2016-03-30 10:28 夜色下的港湾 Views(130) Comments(0) Diggs(0)
#includeusing namespace std;void get(int a){ cout<<__func__<<"int"<<endl;}void get(int *a){ cout<<__func__<<"int*"<<endl;}int main(){ ... Read More
posted @ 2016-03-30 10:27 夜色下的港湾 Views(156) Comments(0) Diggs(0)
#includeusing namespace std;int i =0;void init_cpu(){ cout<<++i<<" "<<__func__<<endl;}void init_serial(){ cout<<++i<<" "<<__func__<<end... Read More
posted @ 2016-03-30 10:25 夜色下的港湾 Views(118) Comments(0) Diggs(0)
#includeusing namespace std;//typedef int (*PGET)(int);int get(int a){ cout<<__func__<<" "<<a<<endl; return a;}using PGET = int(*)(int)... Read More
posted @ 2016-03-30 10:19 夜色下的港湾 Views(69) Comments(0) Diggs(0)
#includeusing namespace std;//函数前面有inline关键字修饰,那么这个函数就叫做内联函数//内联函数可以加速程序执行的时间//内联函数一定是代码量极少的函数,且不要有浮点操作;//内联函数的缺点是增加了代码段的数量,耗费更多的内存//典型的以空间换时... Read More
posted @ 2016-03-30 10:18 夜色下的港湾 Views(108) Comments(0) Diggs(0)
#includeusing namespace std;int get(int a=10){ return a;}double get_cycle_area(double r,double pi=3.1415){ return pi*r*r;}double get_cy... Read More
posted @ 2016-03-30 10:15 夜色下的港湾 Views(99) Comments(0) Diggs(0)
#includeusing namespace std;//函数重载:指的是有两个或以上的函数名字相同,但是函数参数的类型或个数不同;int MAX(int a,int b){ coutb?a:b;}char MAX(char a,char b){ coutb?a:b;... Read More
posted @ 2016-03-30 10:12 夜色下的港湾 Views(167) Comments(0) Diggs(0)
1.#include#includeusing namespace std;int main(){ vector v(5); cout#includeusing namespace std;int main(){ vector v(5); cout::ite... Read More
posted @ 2016-03-30 10:08 夜色下的港湾 Views(236) Comments(0) Diggs(0)