Code:
#include <iostream>
#include <string>
using namespace std;
class Specs_M{
private:
string height;
string weight;
public:
Specs_M(string y, string z){
setweight(y);
setheight(z);
}
void setweight(string x){
weight=x;
}
string getweight(){
return weight;
}
void setheight (string x){
height=x;
}
string getheight(){
return height;
}
};
class Specs_P {
private:
string age;
string weightp;
string heightp;
public:
Specs_P(string z){
setage(z);
}
void setage(string x){
age=x;
}
string getage(){
return age;
}
/*Specs_P(string g, string f){
setweightp(g);
setheightp(f);
}*/
void setweightp(string y){
weightp=y;
}
string getweightp(){
return weightp;
}
void setheightp(string v){
v=heightp;
}
string getheightp(){
return heightp;
}
};
int main() {
Specs_M object1("136 lbs","70 inches");
cout<<object1.getweight()<<"\n"<<object1.getheight()<<endl;
Specs_P object2("Age of user: unknown");
cout<<object2.getage()<<endl;
string g;
cout<<"Enter your weight in lbs with units."<<endl;
cin>>g;
Specs_P object3;
object3.setweightp(g);
string f;
cout<<"Enter your height in inches with units."<<endl;
cin>>f;
// Specs_P object3(g,f);
Specs_P object4;
object4.setheightp(f);
cout<<"Your weight is:"<<object3.getweightp()<<"\n Your height is:"<<object4.getheightp()<<endl;
return 0;
}
In the code above, I removed the constructors by commenting them off. Instead, I wanted to set the variables through an object. However, when I run the code, I get an error message pertaining to the Specs_P object3; and Specs_P object4;.
The message is no matching functions for call to Specs_P::Specs_P().
Why is this?
Any help is appreciated. thanks