01 2022 档案
摘要:默认参数是静态绑定的,而虚函数是动态绑定的。 默认参数的使用要看指针或者引用本身的类型,而不是对象的类型 #include <iostream> using namespace std; class Base { public: virtual void fun ( int x = 10 ) { c
阅读全文
摘要:int n=1,m=2; const int* a=&n; cout<<*a<<endl; a=&m; cout<<*a<<endl; int* const b=&n; cout<<*b<<endl; *b=10; cout<<*b<<endl; const int* a中,const修饰变量,表示
阅读全文
摘要:类似于这个例子 #include <iostream> using namespace std; void sw(int a,int b) { int tmp=a; a=b; b=tmp; } void sw1(int* a,int* b) { int tmp; tmp=*a; *a=*b; *b=
阅读全文