using语法
-
用于声明已有的命名空间,表明在本声明后,可以使用该命名空间中的变量和函数,而不需要加范围修饰符"::".
using namespace std;
-
令一种声明方式
//你可能在标准库中见到过很多这样的语句,属于使用哪个就声明哪个 using std::cout; using std::cin;
-
变量名替换
using _int32_ = int; using Vec = vector<int>; //等价于 typedef int _int32_; typedef vector<int> Vec;
-
函数名替换(函数指针)
using Func = void(*)(const Content& content); void example(const Content& content); Func vari = example; //(example是具体的函数指针)
-
模板名称替换
template<class CharT> using mystring = std::basic_string<CharT,std::char_traits<CharT>>; mystring<char> str;
//<string>和<string_fwd.h>都有以下typedef: typedef basic_string<char> string;
typedef语法
-
变量名替换
typedef int _int32_;
-
函数名替换
typedef void(*func)(int,int);//注意这里和using的不同 void example(const Content& content); Func vari = example; //(example是具体的函数指针)
-
//<string>和<string_fwd.h>都有以下typedef: typedef basic_string<char> string;