Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function pass by reference

Recently a c++ expert told me that :

void f(int &*r);

is a valid pass by reference example although I thought this is some kind of pointer to a reference which is illegal. From my knowledge the correct form for pass by reference is either form of the following:

void f1(int *&r);
void f2(int &r);

Can you explain the situation of the first example (function f)?

like image 929
dragosb Avatar asked Jan 20 '14 10:01

dragosb


1 Answers

The first one (pointer to reference) is illegal in all versions of C++. The rest two are legal.

The bottomline : Ignore Your Instructor — he/she doesn't know C++, at least in this case.

like image 112
Nawaz Avatar answered Sep 23 '22 23:09

Nawaz