passing object by reference in C++

后端 未结 5 785
有刺的猬
有刺的猬 2020-12-02 07:56

The usual way to pass a variable by reference in C++(also C) is as follows:

void _someFunction(dataType *name){ // dataType e.g int,char,flo         


        
5条回答
  •  不思量自难忘°
    2020-12-02 08:43

    Passing by reference in the above case is just an alias for the actual object.

    You'll be referring to the actual object just with a different name.

    There are many advantages which references offer compared to pointer references.

提交回复
热议问题