1.内联函数 1.1.常量与宏的回顾 (1)C++中的 const 常量可以替代宏常数定义,如: ; //等价于 #define A 3 (2)C++中是否有解决方案,可以用来替代宏代码片段呢? 1.2.内联函数的定义 (1)C++编译器可以将一个函数进行内联编译,被 C++编译器内联编译的函数叫内联函数. (2)C++中使用 inline 关键字声明内联函数.如 inline int func(int a, int b) { return a < b ? a : b; } (3)内联函数声明时…
为了访问公有派生类的特定成员,可以通过讲基类指针显示转换为派生类指针. 也可以将基类的非静态成员函数定义为虚函数(在函数前加上virtual) #include<iostream> using namespace std; class base{ public: /*virtual*/ void who(){ //define this function to virtual will be normal cout << "this is the class of bas…