What is a C++ class?
A class is a user-defined type combining data with the functions that operate on that data.
Study 08 Classes and Objects with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is a C++ class?
A class is a user-defined type combining data with the functions that operate on that data.
What is an object in C++?
An object is an instance of a class. It occupies storage and has a lifetime.
What follows a class definition's closing brace?
The semicolon after a class definition's closing brace is required.
What do data members represent?
Data members represent an object's state; each object has its own non-static data members.
What is a member function?
A member function is associated with a class and operates on a particular object when called with the member-access operator `.`.
What does the implicit `this` pointer refer to?
Inside a non-static member function, the implicit `this` pointer refers to the object on which the function was called.
What does `const` promise on a member function?
A `const` member function promises not to modify the object's observable state through the object on which it is called.
What are the default access levels for `class` and `struct`?
Members of a `class` are `private` by default, whereas members of a `struct` are `public` by default.
What does a constructor do?
A constructor initializes an object automatically when it is created. It has the class's name and no return type.
What determines member-initialization order?
Members are initialized in the order they are declared in the class, not the order written in the initializer list.
What does `explicit` prevent on a constructor?
`explicit` prevents unintended implicit conversions for a constructor, such as rejecting `Meters distance = 5.0;`.
What is encapsulation?
Encapsulation combines state and behavior while controlling access to state. Private data and public operations can enforce valid object states.