33,008
社区成员
发帖
与我相关
我的任务
分享
#include<iostream>
#include<string>
using namespace std;
void f1(int a, int b)
{
cout << "this is odd branch. " << (a + b) << endl;
}
void f2(int a, int b)
{
cout << "this is even branch. " << (a + b) << endl;
}
void (*arr[2])(int, int) = {&f1, &f2};
int main()
{
for(int i = 0; i < 10; ++i)
{
(*arr[(i & 1)])(i, i + 1);
}
return 0;
}