c++知识点
sabcasjkd
是只小猴子
展开
-
[C++]reference variables(引用变量)在pass arguments to functions中的运用
一. reference variable的形式int a;int & b = a; // b is alias(别名) for a[例]#include <iostream>using namespace std;int main(int argc, const char * argv[]) { int a=10; int & b = a;...原创 2019-02-02 13:34:02 · 312 阅读 · 0 评论 -
[C++复习]04| classes and objects(2)
[note 1]The type and scope of each static member variable must be defined outside the class definition.[form]:type class-name::static-member-nametype class-name::static-member-name=initial-value...原创 2019-06-17 21:42:45 · 158 阅读 · 0 评论 -
[C++复习]03|classes and objects
[note 1]We can define a function outside the class definition inline by using inline in the header line of function definition.[example]class A{ ......public: void getNum(int a, int b);}inlin...原创 2019-06-11 20:10:18 · 200 阅读 · 0 评论 -
[C++笔记]02|functions in C++
[note 1]An example of call by reference#include <iostream>using namespace std;void func(int&a){ cout<<"in func------"<<++a<<endl;}int main(int argc, const char *...原创 2019-06-11 18:41:27 · 128 阅读 · 0 评论 -
notes for C++
[C++笔记]01|Tokens, Expressions and Control Structure[C++笔记]02|functions in C++[C++复习]03|classes and objects[C++复习]04| classes and objects(2)[C++复习]05| inheritance[C++复习]06|operator overloading and...转载 2019-06-20 11:34:04 · 141 阅读 · 0 评论 -
[C++复习]11|working with files
[note 1]fstreamWe must include this file in any program that uses files.[note 2]Here are 2 ways to open a file.opening files using constructor(useful when manipulate 1 file)[1]ofstream out...原创 2019-06-20 11:28:33 · 143 阅读 · 0 评论 -
[C++复习]10|managing console I/O operations
[note 1]character by character[1] getchar a;cin.get(a);a=cin.get;these 2 prototypes can be used to fetch a character including the blank space, tab and newline character.[2] putcout.put('x');...原创 2019-06-20 10:33:47 · 147 阅读 · 0 评论 -
[C++复习]09|Exception handling
[note 1]general form of the try and catchtry{ //}catch (type arg){ // }[example 1]//Throw point outside the try block#include<iostream>using namespace std;void divide(int x, int ...原创 2019-06-20 09:42:05 · 160 阅读 · 0 评论 -
[C++复习]08|Templates and STL
[note 1]Function templatestemplate <class T>return-type function-name (arguments of type T){ function body}在这里插入代码片[example 1]#include <iostream>using namespace std;template&...原创 2019-06-20 09:15:39 · 122 阅读 · 0 评论 -
[C++复习]07| polymorphism and virtual function
[note 1]#include <iostream>using namespace std;class Base{public: void display(){cout << "\n Display base ";} virtual void show(){cout << "\n show base";}};class Der...原创 2019-06-19 23:49:32 · 152 阅读 · 0 评论 -
[C++复习]06|operator overloading and type conversion
[note 1]The operators that can only be overloaded as non-static member function of some classes:= , [] , () , ->(As for the static function, it doesn’t has the this pointer, so the operator can...原创 2019-06-19 21:47:56 · 227 阅读 · 0 评论 -
[c++] throw-catch问题1
TEST 1#include <iostream>using namespace std;int main(int argc, const char * argv[]) { try{ try {throw "help...";} catch(int){cout<<"1in fc...int hanlder"<<end...原创 2019-05-30 18:50:11 · 119 阅读 · 0 评论 -
[C++复习]05| inheritance
[note 1]Protected derivationBoth the public and protected members of the base class become protected members of the derived class.[note 2]Ambiguity Resolution in inheritance#include<iostream...原创 2019-06-18 12:37:23 · 126 阅读 · 0 评论