Topic: C++ Constructors in Derived Classes (Page 1 of 1) |
|
|---|---|
|
Paranoid (IV) Inmate From: Under the Bridge |
posted 11-07-2006 12:36
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 |
posted 11-07-2006 17:18
|
|
Paranoid (IV) Inmate From: Under the Bridge |
posted 11-08-2006 13:25
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 |
posted 11-08-2006 14:08
Hey is there no C++ Guru here....or is the problem that hard... |
|
Paranoid (IV) Inmate From: Madison, Indiana |
posted 11-08-2006 18:35
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 |
posted 11-08-2006 21:33
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 |
posted 11-09-2006 07:54
Done. |