#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main()
{
int func1(int i, int j);
int func2(int i, int j);
int func3(int i, int j);
int func4(int i, int j);
vector<int(*)(int, int)> vec;
//以下几行代码不影响程序运行,但是存在认知偏差!
int(*tp(int, int)); //tp是什么鬼?
typedef int(*typetest2(int, int)); //typetest2是什么数据类型?
typetest2 tp3; //tp3又是什么鬼?
//以下几行代码不影响程序运行,但是存在认知偏差!
int(*p1)(int i, int j);
int(*p11)(int, int);
p1 = &func1;
p11 = func1;
typedef int(*type2)(int, int);
typedef int(type22)(int, int);
type2 p2;
type22 *p22;
p2 = func2;
p22 = func2;
using type3 = int(*)(int, int);
using type33 = int (int, int);
type3 p3;
type33 *p33;
p3 = func3;
p33 = func3;
vec.push_back(p1);
vec.push_back(p2);
vec.push_back(p3);
vec.push_back(func4);
vec.push_back(p11);
vec.push_back(p22);
vec.push_back(p33);
vec.push_back(&func4);
for (auto p : vec)
cout << (*p)(17, 6) << endl;
return 0;
}
int func1(int a, int b)
{
return a + b;
}
int func2(int a, int b)
{
return a - b;
}
int func3(int a, int b)
{
return a * b;
}
int func4(int a, int b)
{
return a / b;
}