Consider the following class and answer questions after this class #include using namespace std; class Account { public: Account(string accountName, int initialBalance) { name=accountName; if...









Consider the following class and answer questions after this class



  #include


  using namespace std;


  class Account


  {


      public:


         Account(string accountName, int initialBalance)


        {


               name=accountName;


               if (initialBalance > 0) {


               balance = initialBalance;


               }


        }


      void deposit(int depositAmount) {


              if (depositAmount > 0) {


              balance = balance + depositAmount;


               }


       }


      int getBalance() const {


             return balance;


       }


      void setName(string accountName) {


            name = accountName;


      }


      string getName() const {


           return name;


      }


  private:


      string name;


      int balance;


};



a)     Rewrite the above class. Write prototype of all functions inside class and definition outside.


b)    Write two friend functions to change the value of name and balance.


c)     Write a print function and use this pointer in the body.


d)    Consider the private data members are constant. Create a constructor which initializes the private members.




Jun 01, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here