Operator Overloading (7) Flashcards
1
Q
What is operator overloading?
A
Allows programmer to supply behavior to code that is usually built in
2
Q
What two operators does the compiler generate a default implementation for?
A
= and &
3
Q
What does overloading not change?
A
precedence, associativity, arity, how it works on built in types
4
Q
Does overloading - and = overload -=?
A
Nope
5
Q
What are two things overloading an operator cannot do?
A
Create new operator symbols
Change the syntax (% cannot be changed to use 1 operand)
6
Q
When an operator is a member function, how does it access private data?
A
Friend function
Use accessors/ mutator functions
7
Q
What is the difference between overloading and overriding?
A
Overloading: multiple function with same name occur in the same scope but with different signatures Overriding: derived class function has the same name and signature as a base class virtual function (inheritance)