OOP test 1

¡Supera tus tareas y exámenes ahora con Quizwiz!

Default constructor

is provided if a class does not explicitly include constructors and has no parameters.

const data members and reference data members must have their values set in the ____________________________ portion of the constructor

member initialization list

The __________________ operator automatically creates an object of the proper size, calls the constructor for the object and returns a pointer of the correct type.

new

static

one shared among the class

given the class def. add some prototypes needed to overload

ostream& operator<<(ostream& out, myarray array) bool Rational::operator<=(const Rational& rValue) const

A derived class can ______________________ a base-classes member functions by supplying a new version of that function with the same signature.

override

Apply C++ 11's ________________ keyword to every overridden function in a derived-class. This causes the compiler to check whether the base class has a member function with the same name and parameter list.

override

int*& p;

p is a reference to a pointer to an integer

C++ enables __________________________. This enables us to write programs that process objects of classes that are part of the same class hierarchy as if they were all objects of the hierarchy's base class. This allows us to "program in general" rather than "program in specific".

polymprphism

The "dummy" or "garbage" parameter is used with the _____________ increment operator?

post increment

Only members and friends of a base class, and members and friends of a derived class may access a base class's ____________________ members.

protected

When you use _____________________ inheritance all of the public and protected members in the base class become protected in the derived class

protected

Each object of a class has its own copy of all the data members of the class. In certain cases all objects of a class should share only one copy of a variable. A____________________ class variable is used for these and other reasons.

static

When a virtual function is called using an object by name and using the dot member-selector, what type of binding is used?

static

_________________ member functions are the only member functions that do not receive this as an implicit first argument.

static

Every object has access to its own address through a pointer named _________________________

this

Under public inheritance, derived-class objects can be treated as base class objects. T/F

true

Copy constructor

used when a copy of an object is needed such as passing an object by value to a function

A(n) ____________ function is NOT part of a class' interface; rather, it is a private member function that supports the operations of the class's public member function.

utility

Once a function is declared ___________________ , it remains so all the way down the inheritance hierarchy from that point even if it is not declared as such when a class overrides it.

virtual

When C++ compiles a class that has one or more virtual functions, it builds a ______________________________ for that class. This is used by the executing program to select the proper function implementation each time a virtual function of that class is to be executed.

vtable

Other constructors

will take some other number of parameters

Assume the operator + has been overloaded for the user defined data type Date. Given three Date objects x, y and z, the address of which object will be the "this" pointer passed to operator+? x = y+z

y

Which 3 of the following operators can be used with user defined type without overloading them?

& , =

When calling a virtual function the program will choose the correct implementation according to which of the following:

Object type

void main() { GameBoard& gb = GameBoard::getInstance(); }

Class GameBoard { public: static GameBoard& getInstance(); private: GameBoard(); GameBoard (GameBoard& gameBoard){} static GameBoard ** pGameBoard; } GameBoard ** GameBoard::pGameBoard = NULL;

The process used to resolve which virtual function to call at run-time is called ________________ binding.

Late

A derived class can directly access protected members of its base class. T/F

True

vtable

Virtual function table that makes polymorphism possible. Used when a class has virtual functions and is used to look up where the function is at run time. the vtable contains pointers to the class's virtual table.

Should comparison operator functions be const?

Yes

An "Is a" relationship is represented by ______________ , and a "has a" relationship is represented by _____________

inheritance composition

Which 2 of the following operators cannot be overloaded?

. ::

4 Types of constructors

1. Default 2. Copy 3. Conversion 4.Other

A ________ ____________ function is one with an initializer of = 0 and has been declared virtual.

Pure virtual

A class that is defined to be used as a base class only, meaning there can never be an instance made of this class by itself if called a(n) _________________ base class.

absrtact

protected

accessed from methods, friends, anything that inherits

The member-initializer list is executed ____________ the constructor body.

before

Conversion constructor

called with a single argument and can turn objects of other types into objects of a particular class

public

can be accessed from methods, friends, anywhere

Private

can be accessed from own methods or friends

difference between a class and a struct

classes default everything to private structs default everything to public

Non-abstract classes from which objects can be created are called _______________________.

concrete

what belongs in the member initialization list

constants, references, and calls base class constuctor

A ______________________________ constructor is a single argument constructor that turns objects of other types (including built-in types) into objects of a particular class.

conversion constructor

A base-class initializer can be provided in the derived-class constructor to call the base-class constructor explicitly; otherwise, the derived class' constructor will call the base class's ______________ constructor.

default

what type of constructor is: C::C(int x =1) {}

default, conversion

A ___________ class is more specific than its ___________ class and represents a smaller group of objects.

derived bass

A function with the same name as the class but receded with a tilde character (~) is called the ________________ of that class.

destructor

Provide a virtual base-class _______________________, even if one is not required. Then when an object in the hierarchy is destroyed explicitly by applying the delete operator to a base-class pointer to a derived class object, the entire object will be freed correctly.

destructor

A ____________ cast is used when derived-class pointer is the l-value and a base-class pointer is the r-value in an assignment.

explicit

A constructor that is declared __________________ cannot be used in an implicit conversion.

explicit

Operator overloading can change the meaning of how an operator works on objects of built-in types. T/F

false

Overloading can change the precedence of an operator T/F

false


Conjuntos de estudio relacionados

Studies Weekly 18 - The Germanic Tribes

View Set

OTA BIO WEEK 7 CHAPTER 9 muscles exercise

View Set

CH 6 Business Strategy: Differentiation, Cost Leadership and Blue Oceans

View Set