When doing Function Pointers what is the purpose of using the address-of operator vs not using it?

后端 未结 4 1503
别那么骄傲
别那么骄傲 2021-01-12 06:17

For the following code snippets why would I use one assignment vs another? thx

void  addOne(int &x)
{
    x +=1;
}

void (*inc)(int &x) = addOne;           


        
4条回答
  •  执笔经年
    2021-01-12 06:28

    A function is already a pointer; therefore, you do not need the address operator.

提交回复
热议问题