What is the definition of a class?
A blueprint that describes a set of objects with the same behavior.
True or false: You put data members in the public interface.
False: You want to protect the data members in the private interface.
Where are variables declared?
Private section
Which is constant, a mutator or an accessor?
An accessor
What does OOP stand for?
Object Oriented Programming
True or false: The name of the constructor can be anything
False: Has to have the same name as the class
What are other names for mutators and accessors?
Mutators: setters
Accessors: getters
True or false: Each object has a separate copy of the data members.
True
Which syntax is correct?
a) void Clock. reset()
b) void Clock: reset();
c) void Clock:: reset()
d) void Clock:: reset();
d) void Clock:: reset();
Which of the following is an attribute of Clock class?
a) Hour
b) Move hand
c) Reset clock
d) Page count
a) Hour
What is encapsulation?
The process of providing a public interface while hiding implementation details.
What are the mutator and accessor in the given member functions?
double get_total() const;
void set_total();
void print_welcome();
Accessor: double get_total() const;
Mutator: void set_total();
Why are data members private?
To protect the state of the data members.
Where have we seen Object Oriented Programming before the introduction of classes?
In string objects, cin, and cout
A constructor is a special ______ function that initializes the _____ ________ of an object.
member; data members
Which is the implicit and explicit parameter?
person.set_age(13);
Implicit: person
Explicit: 13
What is wrong with this program?
class Box
{
//code
};
Box(int length, double width)
{//code};
Box(int length, double width)
{//code};
You cannot have two constructors with the same number, type, and order of parameters.