0% found this document useful (0 votes)
11 views1 page

BankAccount Class with Overloaded Constructors

The document outlines the creation of a BankAccount class that utilizes constructor overloading to initialize objects with different data. It specifies the implementation of three constructors: a default constructor, a parameterized constructor with all values, and another that sets a default balance. Additionally, it includes instructions for displaying account details and creating three instances of the class in the main function.

Uploaded by

Suhaib Ahmad
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views1 page

BankAccount Class with Overloaded Constructors

The document outlines the creation of a BankAccount class that utilizes constructor overloading to initialize objects with different data. It specifies the implementation of three constructors: a default constructor, a parameterized constructor with all values, and another that sets a default balance. Additionally, it includes instructions for displaying account details and creating three instances of the class in the main function.

Uploaded by

Suhaib Ahmad
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Task: Create a BankAccount class with Constructor Overloading

Objective:
The objective of this task is to practice constructor overloading and understand how to initialize
objects with different constructors based on the provided data.

Instructions:

1. Create a class named BankAccount. This class should have the following private
member variables:

o string accountHolderName (Name of the account holder)

o string accountNumber (Account number)

o double balance (Balance in the account)

2. Create three constructors (constructor overloading):

o Default Constructor: Initializes the accountHolderName to "Unknown",


accountNumber to "0000000000", and balance to 0.0.

o Parameterized Constructor 1: Initializes the accountHolderName,


accountNumber, and balance with specific values provided by the user.

o Parameterized Constructor 2: Initializes the accountHolderName and


accountNumber with specific values but sets the balance to a default value of
1000.0.

3. Add a member function to display the account details:

o This function will display the account holder's name, account number, and
balance.

4. In the main() function:

o Create three objects of the BankAccount class: one using the default constructor,
one using the parameterized constructor with all three values, and one using the
parameterized constructor with name and account number (balance should
default to 1000.0).

o Display the details of each bank account using the display function.

You might also like