vscode 编译命令:clang++ $fileName -o $fileNameWithoutExt -Wall -std=c++14 -DDEBUG -g3 -Wno-misleading-indentation -fno-ms-extensions -Wno-unused-const-variable
The following assumes familarity with C.
OOP=class, object, inheritence, polymorphism, dynamic binding
return value
check private, accessor
deep copy : this!=&oth
virtual function 不用cast!
check pointer or reference
1byte=8bit(32bit=4byte)
sizeof(long long)=1 byte
cout<<boolalpha; cout<<noboolalpha;
module: R = N – (N/D)*D
++x return variable x
x++ return value of x
//g++ -Wconversion : complier arg for enabling warning for coercion
int n=100;printf("%lf", static_cast<double>(n));
//int x;(cin>>x)==whether input is int
//expression "x=y" return variable x since assignment return r-value
int &x=a,&y=b;//reference varialbes alias
const double &cx=a;//only const reference could accept different type by creating **temporary(dangerous!)** variable of type double
enum bloodtype { A, B, AB = 10, O }; // 0,1,10,11
// int converts to enum is invalid
enum class clothes { RED, BLUE };
enum class pants { RED, BLUE };
clothes a = clothes::RED;
pants b = pants::BLUE;
//The values in plain enums will be implicitly converted to integers
//but the values in class enums do not (so resolve name conflict)
array is a piece of contiguous memory, but also the address of the first element
pointer is pointer variable having its own address
there’s no a variable created to store the address of the first element