When you try to create the object, you try to invoke the default constructor:
FrecuenciasCardiacas ob1;
It is known that it is the default constructor because you are not passing any argument to the constructor. However, the class FrecuenciasCardiacas
does not implement said constructor, but a custom one:
FrecuenciasCardiacas(string nombre)//Constructor
{
nombrePersona=nombre;
}
This constructor disables the constructor by default unless you expressly implement it, which does not happen.
What happens then is that the program should call
FrecuenciasCardiacas::FrecuenciasCardiacas()
But that constructor is not available.
At this point there are two possible solutions:
Universal solution : Implement the default constructor:
class FrecuenciasCardiacas
{
public:
FrecuenciasCardiacas()
{ }
};
If you are with C ++ 11 or higher you can use default
:
class FrecuenciasCardiacas
{
public:
FrecuenciasCardiacas() = default;
};
Customized solution : Removes the custom constructor. This solution is only viable if said constructor is not necessary at all. By not implementing any custom constructor the compiler will create the default constructor transparently:
class FrecuenciasCardiacas
{
private: //Atributos//
string nombrePersona;
public: //Metodos//
void establecerNombrePersona(string nombre)//nombre
{
cout<<"Introduzca nombre: ";
cin>>nombrePersona;
nombrePersona = nombre;
}
string obtenerNombrePersona() const
{
return nombrePersona;
}
};