Final Flashcards
Which of the following statements is true regarding classes and objects?
Member data of a class is in scope inside its member function definitions.
For a class called Monster, which of the following is a conversion constructor, enabling automatic type conversions from type Human to type Monster?
Monster(Human x);
Which of the following would result in a fatal run-time error?
Doing the division (x/y), where x and y are integers and y is 0.
In a class, the typical purpose of a destructor member function is…
To do any final clean-up tasks on an object before it is deallocated.
Which of the following statements about operator overloading is true?
Operator overloading cannot be used to create new operator symbols.
Which of the following describes an implementation of the composition (‘has-a’) relationship?
An object of type Rabbit is declared as member data of class Forest.
Which of the following is not a valid operator overload prototype? (Phrase is a class)
bool operator!< (const Phrase& a, const Phrase& b);
Which of the following is a function that will only allow an L-value to be passed as a parameter? (Assume that Icon is a class)
int Compute(Icon & i) const;
Which of the following is the most appropriate declaration of an accessor function for a class called Grade?
double GetValue() const;
Which of the following is a correct way to declare a member function of a class so that it will be guaranteed to not change the member data of the calling object?
int Convert(float& x) const;
If a binary operator is overloaded and written as a member function of a class, the function takes one parameter
True
The command “g++ -o employee.cpp” invokes the compile stage but not the linking stage of the compilation process.
False
An L-value is an expression that represents a modifiable storage location.
True
A friend of a class has access only to the public section of that class.
False
A class may have more than one destructor.
False
Function calls are matched to their definitions during the compiling stage of a program build (not during the linking stage).
False
If a member data variable of a class is declared to be static, then there is only one copy of it that is shared by all objects of the class.
True
A conversion constructor is a constructor that can be called with only one parameter passed in.
True
A constant object may only make calls to const member functions.
True
Every class has a default constructor
False
If pList is an array of pointers to objects of type Politician, then which of the following is syntactically correct call to the Lie() function of the politician class?
pList[0]->Lie();
Which of the following functions must always exist for a class? (i.e. if you do not create one, the compiler will create one automatically)
operator=
Which of the following is a correct prototype for the assignment operator overload member function in a class called Book?
Book& operator=(const Book &);
A function in a derived class that has the same prototype as a function in its base class is said to _____ the base class function
override