2. Pointer vs referinte Flashcards

1
Q

int i = 10;
int *p = &i;

A

Da

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

int i = 10;
int &refI = i;

A

Da

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

int i = 10;
int *p;

A

Da

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

int i = 10;
int &refI;

A

Compile error –
uninitialized reference

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

int i = 10;
int j = 20;
int *p = &i;
p = &j;

A

Da

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

int i = 10;
int j = 20;
int p = &i;
p++;
(
p) = 30;

A

Da

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

int i = 10;
int j = 20;
int &refI = i;
refI++;
(&refI)++;

A

Eroare ultima linie

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

int i = 10;
char *p = (char *)&i;

A

Da

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

int i = 10;
char &refI = i;

A

Eroare

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

int i = 10;
int *p = &i;
int *p_to_p = &p;
**p_to_p = 20;

A

Da

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

int i = 10;
int &refI = i;
int & &ref_to_refI = refI;

A

Eroare

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

int *p[100];

A

Da

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

int &ref[100];

A

Nu

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

int *p = &int(10);

A

Da

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

const int &refI = int(12);

A

This code will not compile if the
“const” specifier is not used as it
refers to a constant numerical
value.

17
Q

const int &refI = int(12);
int *p = (int *)&refI;

A

Da