c++11 using与typedefine
#include <iostream>
#include <string>
using namespace std;
int myTest(string str, int n)
{
cout << str ;
return n;
}
typedef int(*func)(string, int); // 函数指针
using func2 = int(*)(string, int); // 等价于 typedef int(*func)(string, int);
int main()
{
// 调用方式一:
func f = myTest;
f("hello\n", 1);
// 调用方式二:
func2 f2 = myTest;
f2("wangbb\n", 2);
// 调用方式三:
(*f)("c++\n", 10);
system("pause");
return 0;
}
输出: