Inheritance and Polymorphism

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Mar 2005
Posts: 15
Reputation: jeymine is an unknown quantity at this point 
Solved Threads: 0
jeymine jeymine is offline Offline
Newbie Poster

Inheritance and Polymorphism

 
0
  #1
May 2nd, 2005
Hi Guys,
Kindly help me Solve this. I have already worked on the classes that were inherited and attached after the question is the main part of my program. I have bolded the part in the question below where I need help. Thank you so much.
The question is:
Make an array of BankAcct pointers and assign each of the three object addresses into this array. Set up a loop that asks the user what type of banking transaction he or she wants. For whatever type of transaction, run a for loop and call the appropriate function. After each transaction, call the ShowAll functions, which report all data associated with each object. For example, if the user wishes to deposit $100, then $100 is deposited into each account. (Try to conserve space so that all the data may be written on the screen for each transaction). Be sure to place error messages if the user attempts to perform an illegal transaction (i.e. not enough money in the account to make the requested withdrawal). Your program should ask if he or she wishes to perform another transaction. Quit the program when the user is finished.

  1. #include <iostream>
  2. # include "BankAcct.h"
  3. # include "AtmBankAcct.h"
  4. # include "Gold_BankAcct.h"
  5. using namespace std;
  6. using namsepace Judith;
  7.  
  8. int main()
  9. {
  10.  
  11. //(Objects for the classes)
  12. BankAcct ExpressInc("Dimer", "0123672580", "500.00");
  13.  
  14. //Alternative way
  15. //cout<<" Enter the Name of the Account Holder"<<endl;
  16. //cin>> ExpressInc.setName;
  17. //cout<<" Enter Your Account Number (10 digits):"<<end;
  18. //cin>> ExpressInc.setaccount_Number;
  19. //cout<<" The savings Balance is:" <<endl;
  20. // cin>> ExpressInc.setaccount_Number;
  21. ATM_BankAcct KenyaAirways(" British","0123456290"," 1500.00");
  22.  
  23. //same
  24.  
  25. Gold_BankAcct Student( " Judith", "8005672865" , "25,000.00");
  26.  
  27. cout.setf(ios::fixed);
  28. cout.setf(ios::showpoint);
  29. cout.precision(2);
  30.  
  31. BankAcct *ABank;
  32.  
  33. ABank=&ExpressInc;// Base pointer points to the base class
  34. ABank=&KenyaAirways;// It points to the KenyaAirways
  35. ABank=&Student;//''
  36. int Bankaccounts;
  37. char Select;
  38.  
  39. do
  40. {
  41. cout<<" Welcome to Bank Of Judith! Select one option."<<endl;
  42. cout<<" Select 1. for a Bank Account Transaction "<<\n";
  43. cout<<" Select 2. for a ATM_BankAcct Transaction "<<\n";
  44. cout<<" Select 3. for a ATM_GoldAcct Transaction "<<\n";
  45. cin>> Select;
  46. }while(Select<1||Select>3)
  47. cout<<" You Selected:"<<Select<<endl;
  48. if (Select==1)
  49. {
  50. for( int i=0; i<Bankaccounts;i++)
  51.  
  52. // I could not figure out how to work on from here. The for loop section.
  53.  
  54.  
  55.  
  56. return 0;
  57. }
  58.  
Please Bail me out of this pointers.
Last edited by Dave Sinkula; May 2nd, 2005 at 3:42 pm. Reason: Moved to C/C++ forum from C/C++ Tutorials.
Reply With Quote Quick reply to this message  
Join Date: Apr 2005
Posts: 63
Reputation: marinme is an unknown quantity at this point 
Solved Threads: 1
marinme marinme is offline Offline
Junior Poster in Training

Re: Inheritance and Polymorphism

 
0
  #2
May 2nd, 2005
shouldn't this be posted in the help forum? not in the Tutorials thread?
Yeah... I'm lazy. Deal with it.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC