Free Online Flashcard Deck

10 Building C++ Programs Free Online FlashCards

Study 10 Building C++ Programs with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What four parts commonly organize a beginner C++ program?

Back

Headers and declarations, data types and classes, functions, and main. These parts separate required facilities, data representation, operations, and program coordination.

02
Front

Why should a function usually perform one clear operation?

Back

A function should normally perform one clear operation, making it easier to understand, reuse, and test.

03
Front

Which indices are valid for int values[5]?

Back

The valid indices are 0 through 4. Built-in C++ array indexing begins at zero.

04
Front

What happens when code accesses an array outside its bounds?

Back

It causes undefined behavior. The program may appear to work, produce incorrect results, or fail unpredictably.

05
Front

When should you use indexed versus range-based loops?

Back

Use an indexed loop when the position matters; use a range-based for loop when only each element is needed.

06
Front

What do the C++ pointer operators & and * do?

Back

The address-of operator & obtains an address, while the dereference operator * accesses the object at that address.

07
Front

How should code handle a possibly null pointer?

Back

Check that the pointer is not nullptr before dereferencing it. Dereferencing a null pointer is invalid.

08
Front

What does const after a member function mean?

Back

It promises that the member function does not modify the object. For example, int getValue() const is a read-only operation.

09
Front

What is encapsulation in object-oriented C++?

Back

Encapsulation groups data and operations while controlling access to the data's representation.

10
Front

Why pass an array's size to a function?

Back

The function does not automatically know the array's element count, so the caller must pass the size separately or use a size-aware type.

11
Front

How does C++ access a member through a pointer?

Back

The -> operator accesses a member through a pointer, such as winner->getScore().

12
Front

What does assert do when its condition is false?

Back

It checks an assumption during development; if the condition is false, it reports a diagnostic and terminates the program. Defining NDEBUG disables ordinary assertions.