fork download
  1. #include<iostream>
  2. #include<string>
  3. using namespace std;
  4.  
  5. class Account{
  6. protected:
  7. string accountHolderName;
  8. int accountNumber;
  9. public:
  10. Account(string accNam,int accNum){
  11. accountHolderName = accNam;
  12. accountNumber = accNum;
  13. }
  14.  
  15. };
  16.  
  17.  
  18. class SavingsAccount: public Account{
  19. protected:
  20. float instrestRate;
  21. float balance;
  22. public:
  23. SavingsAccount(string accNam,int accNum,float iRate,float balan ): Account( accNam, accNum){
  24. instrestRate = iRate;
  25. balance = balan;
  26. }
  27.  
  28. void displayDetails(){
  29. cout<<"Account Holder Name is "<< accountHolderName<<endl;
  30. cout<<"Account Number is "<< accountNumber<<endl;
  31. cout<<"interest Rate is "<< instrestRate<<endl;
  32. cout<<"balance is "<< balance<<endl;
  33. }
  34. };
  35.  
  36.  
  37. class CurrentAccount: public Account{
  38. protected:
  39. int overDraftLimit;
  40. float balance;
  41. public:
  42. CurrentAccount(string accNam,int accNum,int oDraLim,float balan): Account( accNam, accNum){
  43. overDraftLimit = oDraLim;
  44. balance = balan;
  45. }
  46.  
  47. void displayDetails(){
  48. cout<<"Account Holder Name is "<< accountHolderName<<endl;
  49. cout<<"Account Number is "<< accountNumber<<endl;
  50. cout<<"Over Draft Limit is "<< overDraftLimit<<endl;
  51. cout<<"balance is "<< balance<<endl;
  52. }
  53. };
  54.  
  55.  
  56. int main(){
  57. SavingsAccount sacc("Minhaj",101,10,2000);
  58. sacc.displayDetails();
  59.  
  60. CurrentAccount cAcc("Korim",100,10,5000);
  61. cAcc.displayDetails();
  62. }
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
Success #stdin #stdout 0s 5312KB
stdin
Standard input is empty
stdout
Account Holder Name is Minhaj
Account Number is 101
interest Rate is 10
balance is 2000
Account Holder Name is Korim
Account Number is 100
Over Draft Limit is 10
balance is 5000