一、using新用法
template.h
#pragma once
#include <iostream>
#include <map>
template <typename wt>
struct map_s
{
typedef std::map<std::string, wt> type;
};
//C++11
template <typename T>
using str_map_t = std::map<std::string, T>;
int RealFunc(int i, int j)
{
return i + j;
}
typedef int(*FuncType)(int, int);
using FuncType = int(*)(int, int);
typedef unsigned int uint_t;
using uint_t = unsigned int;
main.cpp
#include <iostream>
#include "template.h"
using namespace std;
int main()
{
map_s<int>::type map1;
map1.insert({ "first", 1 });
str_map_t<int> map2;
map1.insert({ "second", 1 });
FuncType funcType = RealFunc;
funcType(1, 2);
}
using比typedef在定义类型上更人性化。
二、类成员指针
#inclu