I saw someone using this
void methodA(const int*& var);
in one answer, but couldn't understand what the argument means.
AFAIK:
const int var
=> const value which can't be changedconst int* var
=> pointer to int which is const i.e *var can't be changed but var can be changedconst int& var
=> reference to const int i.e value of var can't be changed
What does const int*& var
mean, and is const int& *var
also possible?
Can you please give some example as well, like what can be done and what can't be done with it?
UPDATE :
I am not sure if I am thinking right way, but I began to think reference as alias of the variable that was pass as argument, so const int * p; methodA(p) => here we are passing p as const int * but we dont know if this is pass by value or what until we see the definition of method A,
so if methodA is like this methodA(const int * & p2) ==> here p2 is another name to p, i.e. p and p2 are same from now on and if methodA(const int* p2) ==> here p2 is passed as value i.e p2 is just local to this method,
please correct me if I am thinking wrong way ? If yes, I might need to study some more about this ? Can you please point some nice references ?
UPDATE 2 If some beginner like me want to know more about this thing, you can use c++decl / cdecl program, which I just discovered to very useful from here
$ c++decl
Type `help' or `?' for help
c++decl> explain const int&* p
declare p as pointer to reference to const int
c++decl> explain const int*& p
declare p as reference to pointer to const int
But as every one here pointed, first example isnt legal in C++.
Thanks