The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
I need an example of how I might replace 'void' with 'string' in a class. Lecturer specifically wants us to use string. Attached is the scenerio
Thanks
Â
Lecturer wants this as the header file:using namespace std;class BankAcct {public:BankAcct(int a, int b);string display();// member function to display toscreen account number and pinstring show();int get_acc_num();int get_pin_num();private:int account_number;int pin;};This is what I have written:using namespace std;class BankAcct {public:BankAcct(int a, int b);// constructor for bank account data.void display();// member function to display toscreen account number and pinint get_acc_num();int get_pin_num();private:int account_number;int pin;};BankAcct::BankAcct(int a, int b):account_number(a), pin(b) {}// accountnumber and pin number.void BankAcct::display() {// function to display account number and pin.cout<< endl <<"Account number: 324-001-"<< account_number <<"\n Pin code:"<< pin;}int BankAcct::get_acc_num() {return account_number;}int BankAcct::get_pin_num() {return pin;}
Attachments: