create a class in C++ having
the following 4 private members:
one double variable representing the balance of a bank account
on string variable representing the bank account number
a function to deposit money from the bank account
a function to withdraw money from the bank account
the following 2 public members:
-two wrapper functions.
- one parameterless constructor
- one constructor initializing the account balance and account number
class Transaction
{
// private data member
double balance; // balance
string account_num; // account number
void deposit(int amount) // deposit function taking
the amount as parameter
{
balance= balance+amount;
}
void withdraw(int amount)
{
balance= balance-amount;
}
public:
Transaction() // constructor
{
balance=0;
account_num="";
}
Transaction(int acc_bal, string acc_num) //constructor
with parameters
{
balance=acc_bal;
account_num= acc_num;
}
}
Get Answers For Free
Most questions answered within 1 hours.