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

后端 未结 4 1548
别那么骄傲
别那么骄傲 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-12 06:34

    Brevity, style. It's the same with using * when calling them.

    Also note array vs &array[0].

提交回复
热议问题