1. 程式人生 > >函式指標的簡單舉例

函式指標的簡單舉例

#include <iostream>
using namespace std;

void A(int a, int b)
{
    std::cout << "AAA:" <<a << " " << b << std::endl;
}

void B(int a)
{
    std::cout << "BBB:" <<a << std::endl;
}

typedef void (*FUNC_A)(int a, int b);
typedef void (*FUNC_B)(int a);

void AB(FUNC_A fuc_a, FUNC_B fuc_b, int a, int b)
{
    fuc_a(a,b);
    fuc_b(a);
}

int main()
{
    int a = 10;
    int b = 11;

    AB(A, B, a, b);
    return 0;
}