passing object by reference in C++

后端 未结 5 784
有刺的猬
有刺的猬 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:29

    One thing that I have to add is that there is no reference in C.

    Secondly, this is the language syntax convention. & - is an address operator but it also mean a reference - all depends on usa case

    If there was some "reference" keyword instead of & you could write

    int CDummy::isitme (reference CDummy param)
    

    but this is C++ and we should accept it advantages and disadvantages...

提交回复
热议问题