Operator Overloading Flashcards
What is an example of an overloaded operator built into c++?
«_space;stream insertion/bitwise left shift operator
When do + and - perform differently?
Depending on arithmetic type (int, float, pointer)
What is an alternative to overloaded operators?
Explicit function calls
What namespace does string belong to?
std
What overloaded operators does string provide?
Equality, relational, assignment, addition assignment, and subscript
What is boolalpha?
Stream manipulator
Displays true or false instead of 1/0
How to indicate string object literal?
Place letter s immediately following closing “ of string literal
Member function of string that return substring?
substr
Which string overloaded operator does not perform bounds checking?
[]
How to bounds check with string?
Member function at returns reference if subscript is valid
How to overload an operator?
Function definition with keyword operator followed by operator being overloaded
Operators overloaded must be what type of member functions?
Non-static
Must be called on an object
Which operators can be used on class objects without being defined?
=, &, and ,
Can you change precedence or associativity by overloading?
No
The number of operands an operator takes can…..
Not be changed