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.
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;
}
};
Comments
Leave a comment