Define a class for a bank account that includes the followin

Define a class for a bank account that includes the following data members: Name of the depositor Account number Type of account Balance amount in the account The class also contains the following member functions: A constructor to assign initial values. Deposit Function to deposit some amount. It should accept amount in parameter. Withdraw Function to withdraw an amount after checking the balance. It should accept amount as parameter. Display Function to display name and balance. Overload Binary + operator that adds the balance of one account to another account. It should accept an object as parameter and adds the values of parameter to the calling object.

Solution

class BankAccount
{
//Name of depositor
string depositorName;
  
//account number
int accountNumber;
  
//type of account
string typeOfAccount;
  
//balance amount in account
float balance;
  
   /*A constructor will have exact same name as the class name and it does not have any return type at all, not even void. Constructors can be very useful for setting initial values for certain member variables.*/

BankAccount();

//Member functions can be defined within the class definition or separately using scope resolution operator ::.
// Deposit Function
Deposit(float amount)
{
balance=balance + amount;
return balance;
  
}
  
  
// withdraw function
Withdraw(float amount)
{
balance=balance - amount;
return balance;
  
}
  
// Display function
Display(string name, float blance)
{
// it will display name and balance
}
};

---------------------------------------------------------------------------------------------

If you have any query, please feel free to ask.

Thanks a lot.

 Define a class for a bank account that includes the following data members: Name of the depositor Account number Type of account Balance amount in the account

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site