What does a C++ class define?
A class defines a user-defined type, including its representation, behavior, and interface.
Study 09 Introduction to Object-Oriented Programming with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What does a C++ class define?
A class defines a user-defined type, including its representation, behavior, and interface.
What is an object in OOP?
An object is an instance of a class: a concrete value that combines state with operations on that state.
What is a class invariant?
An invariant is a condition that should remain true for every valid object, such as a bank balance that cannot be changed through unrestricted outside access.
What does abstraction mean in OOP?
Abstraction exposes an object’s essential operations while hiding implementation details that callers do not need to know.
What does `= 0` mean on a virtual function?
A pure virtual function is declared with `= 0`; a class containing one is abstract and cannot be instantiated directly.
What is encapsulation?
Encapsulation combines data with the operations that manage it and controls access to the internal representation.
Who can access a C++ `private` member?
A `private` member is accessible only to the class’s members and permitted friends; outside code must use the public interface.
What are C++'s default member access levels?
Members of a `class` are `private` by default, while members of a `struct` are `public` by default.
What relationship does composition model?
Composition builds a class by storing objects of other classes as members; it expresses a “has-a” relationship.
When should inheritance be used?
Inheritance defines a new class in terms of an existing base class and can express a specialized, substitutable form of that base.
What does `override` verify in C++?
The `override` specifier asks the compiler to verify that a derived member actually overrides a virtual base member.
What is dynamic dispatch?
Dynamic dispatch selects the implementation at runtime based on the concrete object, even when called through a base reference or pointer.