I’m novice at C++, and I want to understand the difference between the examples below.
We can’t create function
void someFunc(int &*a){
int *b=new int; //just for example
a=b;
}
but using typedef
typedef int* pint;
void someFunc(pint &a){
int *b=new int; //just for example
a=b;
}
everything is alright.
Is it just a compiler trick, or is the reason for such behavior more complicated?
pint& ais equivalent toint*& a, notint&* a. You can’t have a pointer-to-reference type in C++, but you can have a reference-to-pointer type.