CMSC 341 Fall 1998 Homework #1 Section 101 Due Thursday 9/17/98 before class Section 201 Due Monday 9/21/98 before class Homework soultions should be handwritten and submitted on hard copy. Homework must be READABLE. If we can't read it, we can't grade it, so it must be wrong. The value assigned to each question is listed at the end of the question. This homework has 30 total points. 1. Explain the difference between operator overloading as a member function and as a friend function. (2 points) 2 (a) Write the class defintion for class XYZZY which has the following properties: (5 points) private data member ints x, y and z public constructor that assigns values to x, y and z with default values 1, 2 and 3 respectively public accessor functions for x, y and z public friend function F that returns the minimum of x,y and z (b) Implement the constructor using an intialization list (3 points) (c) Implement the function F (3 points) 3. List the restrictions of C++ opeator overloading. In one sentence, explain why these retrictions exist. (3 points) 4. (a) What is a copy constructor? (3 points) (b) When will a copy constructor be called? (3 points) (c) For any arbitrary class FOO, explain why the following is not correct for FOO's copy constructor prototype. (3 points) FOO (FOO foo); 5. Briefly explain what conversion constructors and coversion (cast) operators are. Use the Rational class we discussed in class for examples. (5 points)