Chapter 10 Flashcards
True or False:
A class is an example of a structured data type.
True
True or False:
In C++, class is a reserved word and it defines only a data type.
True
True or False:
If the heading of a member function of a class ends with the word const, then the function member cannot modify the private member variables, but it can modify the public member variables.
False
True or False:
In C++ terminology, a class object is the same as a class instance.
True
True or False:
Given this declaration:
class myClass
{
public:
void print(); //Output the value of x;
MyClass();
private:
int x;
};
MyClass myObject;
The following statement is legal:
myObject.x = 10;
False
True or False:
If an object is declared in the definition of a member function of the class, then the object can access both the public and private members of the class.
True
True or False:
If an object is created in a user program, then the object can access both the public and private members of the class.
False
True or False:
You can use arithmetic operators to perform arithmetic operations on class objects.
False
True or False:
As parameters to a function, class objects can be passed by reference only.
False
True or False:
The public members of a class must be declared before the private members.
False
The components of a class are called the ________ of the class
members
Which of the following class definitions is correct in C++?
class studentType
{
public:
void setData(string, double, int);
private:
string name;
};
If a member of a class is ________, you cannot access it outside the class.
private
A class and its members can be described graphically using a notation known as the ____ notation.
UML
The word ______ at the end of several of the member functions in the accompanying figure class clockType specifies that these functions cannot modify the member variables of a clockType object.
const
Consider the UML class diagram shown in the accompanying figure. Which of the following is the name of the class?
clocktype
Consider the UML class diagram shown in the accompanying figure. According to the UML class diagram, how many private members are in the class?
three