Classes
Member Functions
Function Definition
Calling Functions
Error Finding
100

What is a class that is pre-defined in C++

String

100

What does a constructor do?

Defines a default variable of a class

100

What does it mean if there is a void in front of a function?

The function does not return anything.

100

How would someone call the function "add_item" in the "cashier" class where the value of the variable is (15)

cashier.add_item(15);

100

What is the error in the following code?

void cashier::get_total() const;

There shouldn't be a void before the function.

200

Why would we use a class?

For code where we could need multiple variables with special properties.

200

What does a getter do?

Returns the value of a variable in a class.

200

What type of function is this:

void teacher::add_grade(letter_grade)

A setter.

200

How would someone call the function below?

void cat::sleep(){

time_slept++

}

cat.sleep();

200

What is the error in the following code?

class cashier{

public:

double money;

cashier();

private:

double total;

}

The data member "money" was defined in the public section.

300

What are the two sections in the public interface?

the public and the private sections.

300

What does a setter do?

Sets the value of a variable in a class.

300

What type of function is this:

string teacher::get_name() const;

A getter.
300

How would someone call the function "set_price" in the "cashier" class where the value of the variable is (26)

cashier.set_price(26);

300

What is the error in the following code?

void cashier::set_total(total){

total = price - money;

return total;

}

there can not be a return in a void function.

400

What does a class do?

Defines a new type of variable with properties and functions

400

Why do we need to define a blank constructor?

So that there is a variable to change later.

400

What do the member functions do?

They can set and return values for variables inside of a class.

400

How would someone call the function below?

string cat::set_name(new_name){

name = new_name;

}

cat.set_name("Cat");

400

What is the error in the following code?

void cashier.set_total(total){

total = total - money;

}

the cashier.set_total should be cashier::set_total

500

What makes up the public interface of a class

member functions, data members, and constructors

500

What would the function calling look like for a function named add_grade() in the class teacher.

teacher.add_grade()

500

What would a getter function in the class "teacher" called count_students look like?

int teacher::count_students() const;

500

How would someone call the function below?

string teacher::set_subject(new_subject){

subject = new_subject;

}

teacher.set_subject("coding");

500

What is the error in the following code?

int cashier::give_change(change_owed){

change_owed = change - change_owed

}

The function does not return any value.

M
e
n
u