Recall & Review
beginner
What is a class in C++?A class is a blueprint or template for creating objects. It defines properties (data members) and behaviors (member functions) that the objects created from the class will have.Click to reveal answer
beginner
What is an object in C++?
An object is an instance of a class. It holds actual values for the properties defined by the class and can use the behaviors (functions) defined in the class.Click to reveal answer
beginner
How do you define a simple class with one integer property and a function to set it?Example:
class MyClass {
public:
int value;
void setValue(int v) {
value = v;
}
};Click to reveal answer
intermediate
What is the difference between public and private members in a class?
Public members can be accessed from outside the class, while private members can only be accessed from within the class itself.Click to reveal answer
beginner
How do you create an object of a class and call its member function?Example:
MyClass obj; // create object
obj.setValue(10); // call member function
int x = obj.value; // access propertyClick to reveal answer
What keyword is used to define a class in C++?
✗ Incorrect
The keyword 'class' is used to define a class in C++.
Which of the following is true about objects?
✗ Incorrect
Objects are instances created from classes.
What access specifier allows members to be accessed outside the class?
✗ Incorrect
Public members can be accessed from outside the class.
How do you call a member function named 'setValue' on an object 'obj'?
✗ Incorrect
Use dot notation: obj.setValue() to call a member function.
Which of these is NOT a member of a class?
✗ Incorrect
Objects are instances of classes, not members inside a class.
Explain what a class and an object are in your own words.
Think about how a cookie cutter (class) makes cookies (objects).
You got /3 concepts.
Describe how access specifiers like public and private affect class members.
Imagine a house with a front door (public) and a locked safe inside (private).
You got /3 concepts.