#Vector存放函式指標
int exampleFUnc1(int i, int j) {
return i + j;
}
int exampleFunc2(int i, int j) {
return i - j;
}
int exampleFunc3(int i, int j) {
return i * j;
}
int exampleFunc4(int i, int j) {
__glibcxx_assert(j != 0);
return i / j;
}
typedef decltype(exampleFUnc1) *funcptr;
std::vector<funcptr> vector1;
vector1.push_back(exampleFUnc1);
vector1.push_back(exampleFunc2);
vector1.push_back(exampleFunc3);
vector1.push_back(exampleFunc4);
for (auto &i: vector1) {
std::cout << i(8, 4) << " ";
}
std::cout << std::endl;