| | |
Inheritance and Polymorphism
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Mar 2005
Posts: 15
Reputation:
Solved Threads: 0
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.
Please Bail me out of this pointers.
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.
C++ Syntax (Toggle Plain Text)
#include <iostream> # include "BankAcct.h" # include "AtmBankAcct.h" # include "Gold_BankAcct.h" using namespace std; using namsepace Judith; int main() { //(Objects for the classes) BankAcct ExpressInc("Dimer", "0123672580", "500.00"); //Alternative way //cout<<" Enter the Name of the Account Holder"<<endl; //cin>> ExpressInc.setName; //cout<<" Enter Your Account Number (10 digits):"<<end; //cin>> ExpressInc.setaccount_Number; //cout<<" The savings Balance is:" <<endl; // cin>> ExpressInc.setaccount_Number; ATM_BankAcct KenyaAirways(" British","0123456290"," 1500.00"); //same Gold_BankAcct Student( " Judith", "8005672865" , "25,000.00"); cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2); BankAcct *ABank; ABank=&ExpressInc;// Base pointer points to the base class ABank=&KenyaAirways;// It points to the KenyaAirways ABank=&Student;//'' int Bankaccounts; char Select; do { cout<<" Welcome to Bank Of Judith! Select one option."<<endl; cout<<" Select 1. for a Bank Account Transaction "<<\n"; cout<<" Select 2. for a ATM_BankAcct Transaction "<<\n"; cout<<" Select 3. for a ATM_GoldAcct Transaction "<<\n"; cin>> Select; }while(Select<1||Select>3) cout<<" You Selected:"<<Select<<endl; if (Select==1) { for( int i=0; i<Bankaccounts;i++) // I could not figure out how to work on from here. The for loop section. return 0; }
Last edited by Dave Sinkula; May 2nd, 2005 at 3:42 pm. Reason: Moved to C/C++ forum from C/C++ Tutorials.
![]() |
Similar Threads
- Please help (C++)
- Movie database Help (C++)
- inheritance, polymorphism, and other features (C++)
- Need example of how to use INHERITANCE! (C++)
- Help adding records (ASP)
- Quick Polymorphism Tutorial (C)
Other Threads in the C++ Forum
- Previous Thread: big numbers in C++ 5.4455e07
- Next Thread: please help!
| Thread Tools | Search this Thread |
api array beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion count database delete desktop developer directshow dll download dynamic email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelper iamthwee ifstream input int integer java lib linkedlist linker linux loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive return sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets





