Hi, I'm trying to create a Saving Account derived from a Base Account using only setters and getters. I'm replicating what I have in the Base Account because I don't know which other way to create the Saving Account by using the setters/getters. Now I'm facing a problem with the Constructor in Line 79 that I don't know how to resolve. Thanks!
↓Code↓
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
class Account {
private:
int accountNumber;
double balance;
string fullName;
int phoneNumber;
Savings::Savings(double rate) : interestrate(rate) {} // No default constructor exists for class "Account"/'Account':no appropiate default constructor available
The class Account has a single constructor that requires to pass three parameters. So either you provide these parameter to the constructor within the Savings constructor like so:
Thanks for your comment, Coder777. Even though I tried both of your solutions, I'm still getting more errors. When you mention, "The class Account has a single constructor that requires to pass three parameters. So either you provide these parameter to the constructor within the Savings constructor like so:" You refer to this "Savings::Savings(double rate) : Account{ int no, int p, string fn, double b }, interestrate(rate) {}"?
Great, I understand now everything. Thanks for taking your time and dedication to explain keskiverto. So, in theory, having just one constructor and defining it at the last derivated class is the best option for this case. And seeplus, thank you as well for your answer; believe me, I wanted to post the code as readily as you did, but I don't have an idea of how to do it. Anyways I swear next time, ill find a way to do it, or if someone is so kind to tell me, that would be awesome. Thanks for the help!