Operator Overloading, Templates, & Containers Flashcards

(3 cards)

1
Q

Operator Overloading

A

Providing an additional definition for an operator. It is declared using the keyword operator followed by the symbol for the operator being overloaded.

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

Operator Overloading Rules

A
  1. Binary operators can be defined by either having a member function take one argument or a global function taking two arguments.
  2. For any binary operator @, a@b can be interpreted as a.operator@(b) or operator@(a, b).
  3. Unary operators can be defined by either a member function taking no arguments or a global function takin gone argument.
  4. For any unary operator @, @a can be interpreted as a.operator@() or operator@(a).
  5. For any postfix unary operator @, a@ can be interpreted as a.operator@(int) or operator@(a, int)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly