Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

home / study / engineering / computer science / computer science questions and a

ID: 3594137 • Letter: H

Question

home / study / engineering / computer science / computer science questions and answers / 1. what are the two things that you need to overload an operator for a class? 2. name the operators ...

Question: 1. What are the two things that you need to overload an operator for a class? 2. Name the operato...

1. What are the two things that you need to overload an operator for a class?

2. Name the operators that cannot be overloaded.

3. Within the definition of an operator function, how do you refer to the object as a whole?

4. What is the difference between the two statements return this; and return *this;?

5. What is a friend function?

6. Suppose that the binary operator + is overloaded as a member function for a class. How many parameters does the function operator+ have?

7. Which operators must be overloaded as members of a class?

8.Answer these questions about overloading the stream operators:

In a class, why do you include the functions that overload the stream insertion, <<, and extraction, >>, operators as friend functions?

What is returned by the function that overloads the >> operator for a class?

What is returned by the function that overloads the << operator for a class?

9. What is the purpose of a dummy parameter in a function that overloads the post-increment or post-decrement operator for a class?

10. What type of value should be returned by a function that overloads a relational operator?

11. How many parameters are required to overload:

the pre-increment operator for a class as a member function?

the pre-increment operator for a class as a friend function?

the post-increment operator for a class as a member function?

the post-increment operator for a class as a friend function?

12. When should a class overload the assignment operator and define the copy constructor?

13. What are the three things that you must do for classes with pointer member variables?

Explanation / Answer

1. 1. We need to include the operator function in the definition of class and ,
2. we need to write the definition of the operator function

2. Operators that cannot be overloaded are

?: --> Conditional Operator
. --> Member Selection
:: --> Scope Resolution
.* --> Pointer to Member Operator

Sizeof operator

3. this pointer is used to refer the object as whole in operator function.

4. return this will give the address of the current object and
return *this will give the value of the current object.

According to chegg policy I am able to answer only 4 bits. Hope you understand.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote