[C++] Cum declar un pointer la referinta?

Despre limbajul de programare C++ si biblioteca standard STL (forum moderat)
Post Reply
User avatar
Ovidiu Cucu
Fondator
Fondator
Posts: 3776
Joined: 11 Jul 2007, 16:10
Judet: Iaşi
Location: Iasi
Contact:

[C++] Cum declar un pointer la referinta?

Post by Ovidiu Cucu » 24 May 2011, 08:02

Intrebare
Cum declar pointer la referinta, referinta la referinta, array de referinte?

Raspuns
In limbajul C++, desi sintactic e posibil, toate cele enumerate in enunt NU sunt legale.

Code: Select all

int&* pref = NULL;  // Error: pointer to reference is illegal
void f(int&*);      // Error: pointer to reference is illegal
int&* f();          // Error: pointer to reference is illegal


extern int& &rref;  // Error: reference to reference is illegal
void g(int& &);     // Error: reference to reference is illegal
int& &g();          // Error: reference to reference is illegal

extern int& a[10];  // Error: arrays of references are illegal



Post Reply