Use of the & operator in C++ function signatures

后端 未结 9 972
刺人心
刺人心 2020-11-29 00:36

I\'m currently reading through Accelerated C++ and I realized I don\'t really understand how & works in function signatures.

int* ptr=#
         


        
9条回答
  •  夕颜
    夕颜 (楼主)
    2020-11-29 01:26

    While pass by reference may be implemented by the compiler by passing the address as a pointer, semantically it has nothing to do with addresses or pointers. in simple terms it is merely an alias for a variable.

    C++ has a lot of cases where syntax is reused in different contexts with different semantics and this is one of those cases.

提交回复
热议问题