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
Customerfor that object.You need to provide the balance as well as the
Customerwhen 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 ofSavingsAccountappropriately.That can be implemented properly with: