Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
28 Cards in this Set
- Front
- Back
What is operator overloading and why does C++ provide it?
|
?
|
|
What overloaded operators do you get for free?
|
&
. = -> |
|
What operators cannot be overloaded?
|
.
.* ?: sizeof :: |
|
Restrictions of operator overloading
|
one operand must be of a user defined class
operands must not have default values arity cannot be changed |
|
*This and role in overloading
|
Every member function is passed a reference to the object as *this hidden. The reason why binary overloaded operators only have one parameter.
|
|
Free function overloading requires what?
|
access to private data members by public member functions
|
|
Why declare temporary object of the class in the implemenation of some overloaded functions
|
???? Why ????
|
|
Member binary what is passed implicitly and what is passed explicitly
|
LHS is passed implicitly, RHS is passed explicitly
|
|
Returning a reference to a object that is about to go out of scope?
|
Causes a "dangling pointer"
|
|
Do you return a reference for unary and binary asignment?
|
Yes!
|
|
the minus operator is both binary and unary?
|
True
binary has an operand! unary does not. |
|
Friends have direct access to the private members of the classes they are declared friends of
|
True
|
|
What operands have to be member functions
|
=
() [] -> |
|
operator<< returns a reference to an ostream &
|
True!
|
|
Assignment operator takes a reference paramater and returns a reference
|
True!
|
|
return *this
|
? why return a dereference to this?
|
|
What must you implement if your class has pointers?
|
Default Constructor
Copy Constructor Destructor Assignment Operator |
|
where do you declare static again?
|
static must be redeclared outside the class specification (file scope) so memory can be allocated
|
|
overloading
|
same scope different signature
|
|
overriding
|
different scope same signature
|
|
private members in inheritance
|
only available at same class level scope. have to use public member functions to access
|
|
prot inheritance
public/prot-> prot private->priv |
true
|
|
priv
pub/prot->priv |
in derived clas
|
|
public
public->public prot->prot priv->priv |
true!
|
|
if a derived class constructor fails to call it's immediate parent what happens?
|
it calls it implicitly
|
|
always invoke a parent constructor
|
true
|
|
destructors are not inherited
|
true
|
|
constructors called top down
|
true
|