Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
1.5 kB
1
Indexable
Never
1. Define a class named square which has private data member length as integer type. A
member method set_length() is used to set the length of an object. To calculate the area of
the square, a method named area() is used to take a square object as a parameter and
returns the area of the object. Now create an object of square class, then set the length of
the object and show the area as output.
2. Create a class named Employees with private attributes Name and Salary. Implement a
constructor , to initialize and print the values of these data members when an object of the
class is created. Implement a destructor, which should print the message "Bye Bye
Employee!!" when an object of the class is destroyed.
3. Suppose you have an account in SIBL bank. You have account_no, balance as public
data. You can deposit and withdraw from the account. Now use a constructor to initialize
the information. And implement appropriate functions.
4. Design a class named Geometry that contains functions for calculating the area of various
shapes, such as circles, rectangles, and triangles. Utilize function overloading to create
different versions of the area calculation functions that accept different sets of
parameters, allowing users to input dimensions or specific details as needed.
5. Implement a class Book with a default constructor that sets default values for the title,
author, and publication year. Overload the constructor to allow the user to specify these
values.
Leave a Comment