#include <iostream> using namespace std; class Bank_Transaction { public: Bank_T
ID: 3637543 • Letter: #
Question
#include <iostream>using namespace std;
class Bank_Transaction
{
public:
Bank_Transaction( ); //default constructor
Bank_Transaction(double);
double Check_Balance( );
void Deposit(double);
void Withdrawal(double);
private:
double balance;
};
Bank_Transaction::Bank_Transaction()
{
balance = 0;
}
Bank_Transaction::Bank_Transaction(double amount)
{
balance = amount;
}
double Bank_Transaction::Check_Balance()
{
return balance;
}
void Bank_Transaction::Deposit(double amount)
{
balance = balance + amount;
}
void Bank_Transaction::Withdrawal(double amount)
{
balance = balance - amount;
}
int main()
{
Bank_Transaction my_Acct;
Bank_Transaction your_Acct(10340.85);
cout<<"Your Account Balance = "<<your_Acct.Check_Balance()<<endl;
your_Acct.Deposit(512.30);
cout<<"Your Account Balance = "<<your_Acct.Check_Balance()<<endl;
your_Acct.Withdrawal(8284.56);
cout<<"Your Account Balance = "<<your_Acct.Check_Balance()<<endl;
cout<<"My Account Balance = "<<my_Acct.Check_Balance()<<endl;
my_Acct.Deposit(2516.83);
cout<<"My Account Balance = "<<my_Acct.Check_Balance()<<endl;
my_Acct.Withdrawal(25.96);
cout<<"My Account Balance = "<<my_Acct.Check_Balance()<<endl;
return 0;
}
Question 9: Write the statement(ie. the actual line of code) in the program in Step 2 that initializes the balance of the object “your_Acct”.
Question 10: Give the full name of the function(This is also referred to as the function header) and state the type of the constructor that initialized the object “your_Acct”.
Question 11: What happens if you add the statement “my_Acct.Balance = 0;” to the main function of the program in Step 2 after the object declarations? Explain your answer.
Question 12: What do we mean when we use the following phases?
a. Inside the class
b. Outside the class
Explanation / Answer
Answer to question 12: Nested classes are divided into two categories: static and non-static. Nested classes that are declared static are simply called static nested classes. Non-static nested classes are called inner classes. Static nested classes are accessed using the enclosing class name: class A { class B { code; } code; }
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.