Please help with simple problem [closed]

asked 2019-11-18 15:27:25 -0600

Hi, I am making a program that prints actual mood that the user sets. But I can't find on the internet the right solution of fixing an error: "no matching function for call to 'Mood::setMood(std::__cxx11::string&)'".

main.cpp

#include <iostream>
#include <Mood.h>
#include <string>

std::string input;
std::string *pInput = &input;

int main()
{
Mood mood1;
std::string input;
std::string *pInput = &input;
std::cout << "Enter mood: ";
std::cin >> *pInput;
mood1.setMood(*pInput);

std::cout << mood1.getMood() << std::endl;

return 0;

}

Mood.h

#ifndef MOOD_H
#define MOOD_H
#include <string>


class Mood
{
public:
    Mood(std::string *pInput);
    void setMood(std::string x);
    std::string getMood();

protected:

private:
    std::string mood;
};

#endif // MOOD_H

Mood.cpp

#include "Mood.h"
#include <iostream>
#include <string>

Mood::Mood(std::string *pInput)
{
std::string x;
}

void Mood::setMood(std::string x)
{
mood = x;
}

std::string Mood::getMood()
{
return mood;
}
edit retag flag offensive reopen merge delete

Closed for the following reason question is off-topic or not relevant. Please see http://wiki.ros.org/Support for more details. by gvdhoorn
close date 2019-11-19 02:33:33.864640

Comments

I'm sorry, but this does not seem to be a ROS-related problem or question. It's a general C++ programming issue at this point.

Please post those on more appropriate fora, such as Stack Overflow.

gvdhoorn gravatar imagegvdhoorn ( 2019-11-19 02:34:11 -0600 )edit