Answer to Question #163446 in C++ for Eeshal

Question #163446

Senerio:


ATM (Automated Teller Machine) machines are electronic outlets that allow customers to do their basic transactions without interaction of bank’s representative. While programming this ATM in C++, We have created a class named CUSTOMER which stores customer data (i.e. name, NIC, age, address, account balance and transaction history etc.). There is a friend function that wants to access some private information of the class.


Question:


Being a C++ developer, analyze the whole scenario, what do you think, does a friend function contradict the rules of Encapsulation?


Give your opinion in yes or no with strong reasons.




1
Expert's answer
2021-02-13T05:02:57-0500
   class ATMAccountHolders:public Bank
   {
   string accountHolders;
   string accountHoldersAddress, branch;
   int accountNumber;
   double startBalance;
   double accountBalance;
   double accountInterest;
   double amount;
   int count;
     
   public:
   //void Display_accountBalance();
   void deposit();
   void withdraw();
void details();
   void payBills();
   void accountExit();
   void interest();
     
   ATMAccountHolders()
   {
   accountNumber = 5678;
   accountHolders = "Johhy Dre";
   accountHoldersAddress = "Eastway, House no.36";
   startBalance = 60000.00;
   accountBalance = 20000.00;
   branch = "Pkr";
   amount = 20000;
   }
   };

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment