W2 P2: Pointers, References and Arrays Flashcards

1
Q

Pointer that cannot be dereferenced:

A

nullptr

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

Reasons to use synonym pointer types

A
  • does not require a ‘*’ before each identifier

- more readable and less error prone

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

hexDump() function:

A

The function hexDump() listed below displays the contents of a region of memory regardless of the type associated with that region. The function receives the region’s address and its size in number of bytes. It casts the generic pointer a to a pointer to an unsigned char and displays the contents of c[i] in hexadecimal notation:

ex.
hexDump(&i, 4);

Outputs:
98 09 00 00

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

lvalue reference:

A

an lvalue reference identifies an accessible region of memory.

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

rvalue reference:

A

an rvalue reference identifies:

an object near the end of its lifetime
a temporary object or subobject
a value not associated with an object

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

An lvalue reference requires an initializer unless it:

A

has external linkage

is a class member within a class definition

is a function parameter or a function return type

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

std::ref()

A

returns an lvalue reference to its argument (important of functions in the standard library)

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

std::move()

A

returns an rvalue reference to its argument

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

Range-Based for:

A

A range-based for is an iteration construct specifically designed for use with collections. The collections can be of any form. This construct steps sequentially through the elements of an array without requiring its size:

 int a[]{1, 2, 3, 4, 5, 6};

 for (int& e : a)
     std::cout << e << ' ';
 std::cout << std::endl;  }

A range-based for can infer the type of each element:

for (auto& e : a)

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