FlashKeepers

C and C++ · College · College and University

C++ II: Classes and OOP

C++ classes, constructors and destructors, the rule of three and five, inheritance, virtual functions, operator overloading and friend.

About this set

40 basic cards for College C and C++. Set 2 of 7 in C++. It opens with "What is the default access level for class members in C++?" and "What keyword restricts a class member to be inaccessible outside the class?". Study it alongside the other College sets below.

40 cards · basic cards · AI-written, checked twice. Edit anything.

Study this set free Look inside first Get FlashKeepers for iPhone

Opens in your browser, no account. Get the iPhone and iPad app · Android app

What is the default access level for class members in C++?
Show answerprivate
What keyword restricts a class member to be inaccessible outside the class?
Show answerprivate
How do struct and class defaults differ in C++?
Show answerstruct members are public by default, class members are private by default
What keyword grants derived classes access to a base member while blocking outside access?
Show answerprotected
What is a default constructor?
Show answerA constructor that takes no parameters
What is a parameterized constructor?
Show answerA constructor that accepts one or more arguments to initialize member variables
What is a copy constructor?
Show answerA constructor that initializes a new object as a copy of an existing object of the same class
What is a move constructor?
Show answerA constructor that transfers ownership of resources from a temporary or rvalue object to a new object
When does the compiler automatically generate a default constructor?
Show answerWhen a class defines no constructors at all
How do you prevent the compiler from auto-generating a default constructor?
Show answerDefine at least one explicit constructor or use = delete on the default constructor
What is the primary purpose of a destructor?
Show answerTo clean up resources and deallocate memory when an object is destroyed
How many destructors can a class have?
Show answerExactly one
When is a destructor called?
Show answerWhen an object goes out of scope or is explicitly deleted with the delete operator
What is the Rule of Three?
Show answerIf a class defines a destructor, copy constructor, or copy assignment operator, it should define all three
What is the Rule of Five?
Show answerIf a class defines destructor, copy constructor, or copy assignment operator, it should also define move constructor and move assignment operator

25 more cards in the app

Study this set free