I have seen this question on many other forums but even after following what they said I am still getting errors so I need help. I am trying to inherit the protected and public from mother to daughter while initializing some values for daughter. Here is my code: (Thanks in advance)
#include <iostream>
using namespace std;
class Mother{
private:
int age;
string name;
public:
Mother(string a,string b,int c)
:name(a),familyname(b),age(c)
{
cout<<"The Mother is created\n";
}
void returnname(){
cout<<"My name is "<<name<<" "<<familyname<<"."<<endl;
}
void returnage(){
cout<<"I am "<<age<<" "<<"years old."<<endl;
}
protected:
string familyname;
};
class Daughter
:public Mother
{
private:
int age;
string name;
Daughter(string a,int b)
:name(a),age(b)
{
cout<<"Daughter is created!\n";
}
};
int main()
{
Daughter Do("Sarah",10);
Do.returnname();
Do.returnage();
}
Error message
main.cpp|34|error: no matching function for call to 'Mother::Mother()'|