1、引入命名空间
using namespace std;
using std::cout;
2、引入基类成员
class Base{
public:
void func(){cout << "Base::func()" << endl;}
};
class Derived : public Base{
public:
using Base::func;
void func(int x){
cout << "Derived::func(x)" << x << endl;
}
};
int main(){
Derived d;
d.func(); //Base::func()
d.func(1); //Derived::func(x)
return 0;
}
3、取别名
//给类型取别名
using type = int;
type x = 10;
//给FormatItem类型的智能指针取名为ptr
using ptr = shared_ptr<FormatItem>;
template<class T>
class A{
public:
//给模板类型取别名
using value_type = T;
//T func(){}
value_type func(){}
private:
//T x;
value_type x;
}