Friday, February 27, 2009

OOPS ASSIGNMENT - 7

Constructors and Destructors
1.write a program using constructor to find the area of a rectangle. This includes two data members(length and width), two member functions one is to display the length and width, other is to calculate the area and display that area.

2.Create a class to store a string. Include member functions to input and output the data member. Write the above program using constructor and destructor.

3. Write a C++ program by using the parameterized constructor.

4. Write a program by using the copy constructor concept to accept a number display that number.

5. Implement and test a class complex to store
.Real
.Imaginary

Include following constructors
.Default (to initialize both data members by zero value)
. One argument (to initialize both data members by a single value)
.Multiple argument (to initialize both data members by different value)
· Copy

Include destructor

6. Create a class to store string dynamically
Include following constructors
· Default (to initialize string to null value)
· One argument (to initialize string by a given value)
· Copy

7. WAP to implement a polynomial class having data members’ coefficient, base and power. For example, the polynomial 2x5 has the coefficient 2, base x and power 5. Include default and parameterized constructor and also include a member function evaluate () to find the value of the polynomial.

For example, if the polynomial is 2x5.
X=2, 2x5=64 is the answer.

No comments: