Topics: Object-oriented programming, Subroutine, Method Pages: 2 (464 words) Published: March 22, 2013
CS1133 – OOP & Data Structures Assignment # 2 (Section 5, 6) 15th March, 2013 nd Date of submission: 22 March, 2013

Maximum Marks. 20.

Note: Assignment is required to be submitted in soft copy format, a quiz related to assignment will be held in next week which will contain 50% weight of this assignment. You are required to submit the .cpp files of each of the following programs in a folder whose path will be announced in next class. Please write your name, registration number and section number in form of comments at start of each file.

1. Design a program in C++, to implement a class named “Shape”. It should have following attributes which are required to be defined as private. square_side (int), rectangle_width(int), rectangle_length(int), circle_radius(float) Class should have following member functions and some other member data: a. A parameterized constructor function should allow the initialization of an object of shape class, the parameters of constructor function should contain the default values 0, 0, 0 and 0.0 for squre_side, rectangle_width, rectangle_length and circle_radius attributes. b. A destructor for class is also required to be defined. c. An input function, which should allow user to provide input values for attributes of shape class objects. d. An output function should display the values of attributes of shape class objects. e. A member function calc_squre_area() which should calculate area of square by using attribute square_side. f. A member function calc_rectangle_area() which should calculate are of a rectangle by using attributes rectangle_width and rectangle_length. g. A member function add_shape() which should allow addition of two shape objects by adding their respective attributes. Syntax of function header should be: shape add_shape(shape obj); h. Class should contain a static member data of integer type named “total_shapes” which will be incremented when an object of shape class will be created and decremented when...
Continue Reading

Please join StudyMode to read the full document

Become a StudyMode Member

Sign Up - It's Free