Starting from:
$35

$29

Homework 5 Solution


The goal is this homework is get you familiar with constructors, destructors, default constructors, copy constructors, assignment operators, and the calling sequences of constructors and destructors.

This homework is based upon the three classes of Shape, Square, and Circle that you designed in Homework 4.

    1. You need to add two constructors to each class: a constructor with parameters and a default constructor that has no parameters. In each of the 6 constructors, you need to use cout to print out something to indicate that this constructor is called.

    2. You need to add the destructor to each class. In each destructor, you need to use cout to print out something to indicate that this destructor is called.

    3. You need to add a copy constructor to each class. In each copy constructor, you need to use cout to print out something to indicate that this copy constructor is called.

    4. You need to add an assignment operator to each class. In each assignment operator, you need to use cout to print out something to indicate that this assignment operator is called.

    5. In your main function, you should have the code to instantiate a square object as a variable, and you should also have the code to instantiate a square object using new.

    6. In your main function, you should have the code to instantiate a circle object as a variable, and you should also have the code to instantiate a circle object using new.
    7. In your main function, you should have the code to delete the square object and the circle object that you instantiated using new. Your code should have no memory leaks.

    8. In your main function, you need to put the code that you instantiate a square object as a variable inside of a block {} within the main function.

    9. For each cout statement, you should use endl to make sure that each print is on a separate line.

    10. Copy paste the output of your program into a word file, and for each line of output, you need to explain why your program outputs that line.




Turn in one file via handin: the zip file of (1) your whole NetBean directory and (2) the Word

file. The name of your file should be: LastName_FirstName. For example, if your name is John

Smith, you should turn in two files: Smith_John.zip.

More products