C++: Operator Overloading and Templates Flashcards
What is a friend function?
A function that is related to a class but is not a member function.
Which class elements does a friend function have access to?
Private and Protected Class Elements
How is a friend function declared?
It is declared in the class using the friend keyword and then declared in a normal manner for a function.
Why is operator overloading used?
To make it easier for the user of the class, not the developer of the class.
What is operator overloading?
Giving more than one meaning to an operator when applied to a user defined class.
What type must the first operand be for an overloaded operator?
The same type as the class that the operator belongs to.
What is a template?
An instruction for how to build a family of similar looking functions
How is a class or function defined as a template?
template<typename></typename>