Bank Account class

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

Join Date: Mar 2008
Posts: 1
Reputation: LSUinotep is an unknown quantity at this point 
Solved Threads: 0
LSUinotep LSUinotep is offline Offline
Newbie Poster

Bank Account class

 
0
  #1
Mar 23rd, 2008
I am in the process of making a bank account class. I need to put a copy constructor to compare the checking and savings account. Also I need to learn how to insert the checking and savings accounts. I need an assignment operator to assign the checking account to the saving. Last but not least I need a overloaded operator to find the total of the saving and checking account. Any help appreciated whether you know one thing or two =)

  1. # include<iostream>
  2. void account::withdraw(int amount)
  3. void account::deposit(int amount)
  4. int account::balance(void)
  5.  
  6. {
  7. public:
  8. static int transactions;
  9.  
  10. Account();
  11. Account(const Account &right);// copy cstr
  12. ~Account();
  13.  
  14.  
  15. void withdraw(int);//Take from account
  16. void deposit(int);// Put into account
  17. int balance()const;/ / Read the balance
  18.  
  19.  
  20. Account& operator+(const Account &);
  21. Account& operator=(const Account &);
  22. virtual void account_update(int)=0;
  23. private:
  24. int bal;
  25. };
  26. ostream &operator<<(ostream &, const Account&);
  27.  
  28. {
  29. cout<<"
  30. 1. Deposit
  31. 2. Withdraw
  32. 3. Balance
  33. cin>>choice;
  34. switch(choice)
  35. {
  36. cout<<"
  37. break;
  38. case 1 : obj.deposit();
  39. break;
  40. case 2: obj.withdraw();
  41. break;
  42. case 3 :obj.balance();
  43. break;
  44.  
  45.  
  46. }
  47. void deposit(int)
  48. {
  49. cout <<" Deposit ";
  50. cout<<" Amount being deposited ";
  51. cin>>more;
  52. balance+=more;
  53. }
  54.  
  55. void withdraw(int)
  56. {
  57. cout<<"Withdrawal ";
  58. cout<<" Amount being withdrawed : ";
  59. cin>>amt;
  60. balance-=amt;
  61. }
  62.  
  63. int balance()const;
  64. {
  65. cout<< " Account Balance"
  66.  
  67. cout<<" Your Balance Is"
  68.  
  69. balance= totl
  70. }
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,817
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: Bank Account class

 
0
  #2
Mar 24th, 2008
I assume this didn't compile. I'm not clear what goes with what, whether there is supposed to be a header file or an implementation file, or one big file, or what. At the very top, you have this code:
  1. void account::withdraw(int amount)
  2. void account::deposit(int amount)
  3. int account::balance(void)
Is this supposed to be part of the header? Part of the implementation? If it's part of the implementation, I don't see where it's implemented. If it's part of the header, I don't see any semicolons and I don't think you want the "account::" part in there.

I'm assuming this below is the account class header:
  1. {
  2. public:
  3. static int transactions;
  4.  
  5. Account();
  6. Account(const Account &right);// copy cstr
  7. ~Account();
  8.  
  9.  
  10. void withdraw(int);//Take from account
  11. void deposit(int);// Put into account
  12. int balance()const;/ / Read the balance
  13.  
  14.  
  15. Account& operator+(const Account &);
  16. Account& operator=(const Account &);
  17. virtual void account_update(int)=0;
  18. private:
  19. int bal;
  20. };
But I don't see the line
  1. class account
at the top, so I don't know. You also have a bunch of functions at the bottom that seem to be class functions, but I don't see any "account::" qualifier, so I'm not sure what your intent is. If this is all the code for your class, it has problems. If there is more, post it and tell us what goes with what.
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