Operator Overloading

Ace your homework & exams now with Quizwiz!

What does the prefix operator look like?

++p basically.

What is overloading functions?

Basically same function name, different parameter lists, and two separate function definitions.

Why are we returning a reference or an l-value reference with DArray (the example above)?

Basically to allow modification of the value.

Does every overloaded operator has a distinct (different) signature?

Each overloaded operator has a distinct signature, so that the compiler is able to determine whether it is a prefix or a postfix.

What is a friend function?

It Is a non-member (not a member of a class) function. But has access to all the members (public and private) of the class where the function is declared.

What should operator + be overloaded as?

Operator + should be overloaded as a member function.

What is the difference between function overloading and operator overloading?

With function overloading, functions that have same name. With operator overloading it means customizing an operator to make it work with a class you implemented.

What does the postfix operator look like?

p++ basically. We're overloading postfix as a member function. We add a dummy argument to our operator to distinguish between prefix and postfix operator overloading. We're not returning this b/c. it's altered. We will instead return the value created inside the method itself.


Related study sets

Politeness Theory and Grice's Maxims

View Set

Inverse functions practice & quiz

View Set

Chapter 5: Infant Perception, Learning and Cognition

View Set

Organizational Behavior Review Guide Exam 2 (5-8)

View Set

Pediatric Medication Calculations, Calculation Quiz I, IV dosage calculation practice test, HESI Dosage Calculations Practice Exam, Intravenous (IV) calculations, Intravenous Calculations,

View Set

Ch. 43 Disorders of the male reproductive system

View Set