关于函数指针

#include <iostream>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

struct cwd
{
    int a;
    void (*add)(int , int );
};

void  pluss(int a , int b)
{
    int c=a+b;
    cout<<c<<endl;
}



int main()
{
   
    struct cwd name;
    name.add=&pluss;
    name.add(3,1);

    return 0;
}

函数名是一个地址,可以将他赋值给一个指向函数的指针。前面加了&符号其意义是一样的。
比如定义一个数组arr[],arr表示这个数组的首地址,但&arr同样表示他的首地址。这些都是设计语言时这样规定的
原文地址:https://www.cnblogs.com/cdwodm/p/3932922.html