Free Online Flashcard Deck

7 Pointers and Dynamic Memory Free Online FlashCards

Study 7 Pointers and Dynamic Memory with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What does a pointer store?

Back

A pointer is an object that stores an address, allowing indirect access to another object or function.

02
Front

What does the `&` operator produce?

Back

The address-of operator `&` produces a pointer to an object, such as `int* address = &score;`.

03
Front

What does unary `*` do to a pointer?

Back

The unary `*` operator dereferences a pointer, accessing its target. It can read the target or modify it when the pointer permits modification.

04
Front

When is pointer dereferencing valid?

Back

Dereferencing is valid only when the pointer points to a live object or function. Null, dangling, uninitialized, and otherwise invalid pointers must not be dereferenced.

05
Front

How does pointer arithmetic scale movement?

Back

Within an array, `p + 1` advances to the next element, not necessarily the next byte. The step is scaled by the pointed-to type.

06
Front

Where is array pointer arithmetic defined?

Back

Pointer arithmetic is defined within one array, including the position one past its end. A one-past pointer may be formed but must not be dereferenced.

07
Front

What does subtracting same-array pointers produce?

Back

Subtracting two pointers into the same array gives the number of elements between them, such as `&numbers[4] - &numbers[0]`, which equals 4.

08
Front

What does an array name usually convert to?

Back

In most expressions, an array name converts to a pointer to its first element, so `values` is equivalent to `&values[0]` in that context.

09
Front

How do arrays and pointers differ?

Back

An array owns a fixed number of elements and includes its size in its type; a pointer only stores an address and does not remember the element count.

10
Front

What does `nullptr` represent?

Back

`nullptr` represents a pointer that points to no object or function. It may be compared, copied, or assigned, but it must not be dereferenced.

11
Front

What is a dangling pointer?

Back

A dangling pointer refers to an object whose lifetime has ended. Returning the address of a local variable creates this problem after the function returns.

12
Front

Which deletion matches `new` and `new[]`?

Back

A single object allocated with `new` must be released with `delete`; an array allocated with `new[]` must be released with `delete[]`.