new 动态分配内存和delete 释放空间
int *pn = new int;
*pn = 5;
std::cout<<*pn<<"\n";
pn = new int[30];
pn[0] = 99;
std::cout<<*pn<<"\n";
int *p = new int;
*p = 5;
std::cout<<*p<<"\n";
delete p;
std::cout<<*p<<"\n";
p = new int;
*p = 6;
delete p;
int *a = new int[20];
a[0]= 1;
a[1] = 99;
std::cout<<*a<<"\n";
delete[] a;
std::cout<<*(a)<<"\n";
函数重载:函数名字相同,参数个数或参数类型不同
函数缺省参数
void func(int x1, int x2=2, int x3=3){}
func(10);
func(10,8);
func(10,,8);
内联函数:为了减少函数调用的开销
其本质上是将整个代码块插入到调用语句处
缺点: 可执行程序体积增大
inline int Max(int a, int b ){
return a>=b?a:b;
}