as title says I am having some problems with invoking base class constructor in subclass constructor
Base:
account.h
Account(double, Customer*)
account.cpp
Account::Account(double b, Customer *cu)
{
balance = b;
cust = *cu;
}
Subclass:
savings.h
Savings(double);
savings.cpp
Savings::Savings(double intRate) : Account(b, cu)
{
interestRate = intRate;
}
Error that I am getting is b and cu are undefined. Thanks for help
Think of how you create a
SavingsAccount
.Can you create one using
If you did that, what would be the balance on that object? Who will be the
Customer
for that object.You need to provide the balance as well as the
Customer
when you create aSavingsAccount
. Something like:makes sense. You are providing all the data needed for a
SavingsAccount
. To create such an object, you'll need to define the constructor ofSavingsAccount
appropriately.That can be implemented properly with: