Operator Overloading (7) Flashcards

1
Q

What is operator overloading?

A

Allows programmer to supply behavior to code that is usually built in

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What two operators does the compiler generate a default implementation for?

A

= and &

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does overloading not change?

A

precedence, associativity, arity, how it works on built in types

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Does overloading - and = overload -=?

A

Nope

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

When an operator is a member function, how does it access private data?

A

Friend function

Use accessors/ mutator functions

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
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)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly