Free Online Flashcard Deck

8 Classes and Introductory Object-Oriented Programming Free Online FlashCards

Study 8 Classes and Introductory Object-Oriented Programming with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is a C++ class?

Back

A class is a user-defined type that combines data with the functions operating on that data; its definition describes objects but usually creates none.

02
Front

How do default access rules differ for struct and class?

Back

Struct members are public by default, whereas class members are private by default. Both can contain the same kinds of members.

03
Front

What are data members and member functions?

Back

A data member stores an object’s state; a member function defines an operation associated with that object.

04
Front

What does `const` after a member function mean?

Back

The trailing `const` promises not to modify the object’s observable state, so the function can be called on a `const` object.

05
Front

What does `ClassName::memberName` identify?

Back

The scope resolution operator `::` identifies a class member when that member function is defined outside the class body.

06
Front

What is encapsulation?

Back

Encapsulation combines data and operations while controlling access, allowing a class to enforce rules instead of permitting arbitrary state changes.

07
Front

What do public, private, and protected control?

Back

`public` permits general access, `private` limits access to the class and its friends, and `protected` also permits access from derived classes.

08
Front

What is a constructor?

Back

A constructor initializes an object automatically; it has the class’s name and no return type, not even `void`.

09
Front

Why use a member initializer list?

Back

A member initializer list initializes data members before the constructor body executes and is the preferred initialization method.

10
Front

What does `explicit` prevent on a single-argument constructor?

Back

`explicit` prevents an undesirable implicit conversion by requiring construction to be written explicitly in relevant contexts.

11
Front

When do you use `.` versus `->`?

Back

Use `.` with an object and `->` with a pointer to an object. `pointer->member` is equivalent to `(*pointer).member`.

12
Front

What relationship does public inheritance express?

Back

Public inheritance expresses an “is-a” relationship: a derived object can be treated as an object of its public base type.