C++: Operator Overloading and Templates Flashcards

1
Q

What is a friend function?

A

A function that is related to a class but is not a member function.

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

Which class elements does a friend function have access to?

A

Private and Protected Class Elements

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

How is a friend function declared?

A

It is declared in the class using the friend keyword and then declared in a normal manner for a function.

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

Why is operator overloading used?

A

To make it easier for the user of the class, not the developer of the class.

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

What is operator overloading?

A

Giving more than one meaning to an operator when applied to a user defined class.

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

What type must the first operand be for an overloaded operator?

A

The same type as the class that the operator belongs to.

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

What is a template?

A

An instruction for how to build a family of similar looking functions

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

How is a class or function defined as a template?

A

template<typename></typename>

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