Hi everyone, it's been a long time since I've been here. I've come along way with C++, but I'm stuck with a problem I can't come to figure out: constructor use.
NOTE: I'm not asking you to do the whole problem for me, but simply help with using the constructor correctly!
Here's the problem:
http://www.filecram.com/files/03-20-2008 11;32;08AM.JPG
This is what I have so far:
I know how to use construtors within a class and nested classes, but the problem I'm having are using the three functions - string GetId(), string GetName(), double GetBalance() - with the constructor. How am I suppose to pass the values called by each of the function when they all have a return type?Code:#include <iostream> #include <string> using namespace std; class SavingAccount { private: string IdNo, name; double balance, rate; public: //SavingAccount(string UserID, string UserName); string GetId(); }; string SavingAccount::GetId() { cout <<"Please enter your I.D. number." << endl; cin >> } class ATM { public: SavingAccount amount; }; class User { public: ATM UserAccess; }; int main() { User UserInfo; cout <<"AUTOMATIC TELLER MACHINE PROGRAM" << endl; cout <<"--------------------------------" << endl; cout <<"This program works like an ATM (automatic teller machine) - allowing the user to"; cout <<"withdraw money from their account. We will withdraw $100.00 from the account." << endl; UserInfo.UserAccess.amount.GetId(); system("pause"); return 0; }



LinkBack URL
About LinkBacks



