Topic: C++ Constructors in Derived Classes |
|
---|---|
Author | Thread |
Paranoid (IV) Inmate From: Under the Bridge |
![]() ![]() ![]() ![]() Hi All.... any Guru expert out there...i have the follwing scenario below...and am seeking help from anyone able come up with this small code |
Paranoid (IV) Inmate From: Madison, Indiana |
![]() ![]() ![]() ![]() |
Paranoid (IV) Inmate From: Under the Bridge |
![]() ![]() ![]() ![]() code: #include <iostream.h> class BankAccount { protected: int account_number; char holder [30]; float start_balance; public: BankAccount( int act_no,char* holdr,float stb) { account_number = act_no; strcpy(holder,holdr); start_balance = stb; } void display() { cout<<" Account Number ="<<account_number<<endl; cout<<" Holder ="<<holder<<endl; cout<<" Start Balance ="<<start_balance<<endl; } }; class SavingAccount : public BankAccount { private: int withdrawal_notice; float intrest_rate; public: SavingAccount(int acct_no,char* hldr,float sb,int with_ntc,float int_rt):BankAccount(acct_no,hldr,sb) { withdrawal_notice = with_ntc; intrest_rate = int_rt; } void show() { cout<<"Withdrawal Notice ="<<withdrawal_notice<<endl; cout<<"Intrest Rate"<<intrest_rate<<endl; } }
|
Paranoid (IV) Inmate From: Under the Bridge |
![]() ![]() ![]() ![]() Hey is there no C++ Guru here....or is the problem that hard... |
Paranoid (IV) Inmate From: Madison, Indiana |
![]() ![]() ![]() ![]() O.K. That's a start. You still need to declare the ChequeAccount class. You would do it in a similar way to the way you've declared the SavingAccount class. Then write a small main function to instantiate the two classes with the parameters your problem specifies. |
Maniac (V) Mad Scientist with Finglongers From: Germany |
![]() ![]() ![]() ![]() As far as I read it you're pretty good to go, sorry for not replying earlier, I have this amazingly facinating problem here on my desk code: SavingsAccount sampleSavingsAccount = new SavingsAccount ( whatever your defined parameters were ) ;
|
Paranoid (IV) Inmate From: Under the Bridge |
![]() ![]() ![]() ![]() Done. |