fall_2010_cs201_5
TRANSCRIPT
-
8/7/2019 Fall_2010_CS201_5
1/2
Assignment No. 5
Semester: Fall 2010
CS201: Introduction to Programming
Total Marks: 20
Due Date: Jan 31st ,201
Instructions:
Please read the following instructions carefully before submitting your
assignment:
It should be clear that your assignment will not get any credit if:
The assignment is submitted after due date.
The submitted assignment does not open or file is corrupt.
All types of plagiarism are strictly prohibited.
Note: You have to upload only .cpp file. Assignment in any other forma(extension) will not be accepted. If you will submit code any other file
format like .doc or .txt etc. you will get zero marks.
Objective
The objective of this assignment is to provide hands on experience of using
User defined manipulators
Static member
Copy Constructor
Guidelines
Code should be properly aligned and well commented.
Follow C/C++ rules while writing variables names, function name
etc.
Use only Dev-C++ IDE for this assignment.
Assignment
Problem Statement:
You are required to write a program of class rectangle named CRectanglwhich should draw two rectangles by using iTop, iRight, iBot, and
iLeft. Then program should calculate the area of both. Number o
rectangles should be displayed to user by using static variabl
counter which would keep track of increment or decrement o
rectangles. Dynamically Create another rectangle by using copy
constructor and increment in counter should be displayed on screen
Decrement in static variable counter (after de-allocating memory which
-
8/7/2019 Fall_2010_CS201_5
2/2
was dynamically allocated) should be displayed again on screen.
Sample Output
Area of rectangle 1 is 6400
Area of rectangle 2 is 5600
The number of rectangles is 2
After using copy constructor, total number of rectangles is 3
The number of rectangles is 2
Detailed Description:
1. The class should have 4 members: iTop, iRight, iBot, and iLeft, all of
type int.
2. Area of both rectangles should be calculated by using iTop, iRight,
iBot, and iLeft.
3. It should have a default constructor and a copy constructor.
4. It should have a destructor.
5. It should contain all required getters and setters.
6. It should contain a static member, iRefCount, which keeps track of the
number of CRectangle objects. Increment it in the constructor, and
decrement it in the destructor.
Hint:
CRectangle would implement rectangles by using left, right, top and bottom
and calculate their areas to compare.
GOOD LUCK
Deadline:
Your Assignment solution must be submitted on or before Jan 31st, 2011.