2. Pointer vs referinte Flashcards
1
Q
int i = 10;
int *p = &i;
A
Da
2
Q
int i = 10;
int &refI = i;
A
Da
3
Q
int i = 10;
int *p;
A
Da
4
Q
int i = 10;
int &refI;
A
Compile error –
uninitialized reference
5
Q
int i = 10;
int j = 20;
int *p = &i;
p = &j;
A
Da
6
Q
int i = 10;
int j = 20;
int &refI = i;
&refI = j;
A
Compiler error – trying
to change a reference
that was already
initialized.
7
Q
int i = 10;
int j = 20;
int p = &i;
p++;
(p) = 30;
A
Da
8
Q
int i = 10;
int j = 20;
int &refI = i;
refI++;
(&refI)++;
A
Eroare ultima linie
9
Q
int i = 10;
char *p = (char *)&i;
A
Da
10
Q
int i = 10;
char &refI = i;
A
Eroare
11
Q
int i = 10;
int *p = &i;
int *p_to_p = &p;
**p_to_p = 20;
A
Da
12
Q
int i = 10;
int &refI = i;
int & &ref_to_refI = refI;
A
Eroare
13
Q
int *p[100];
A
Da
14
Q
int &ref[100];
A
Nu
15
Q
int *p = &int(10);
A
Da