In this HackerRank Messages Order problem in c++ you need to create an empty constructor in the Class MessageFactory, and implement a method Message create_message(const string& text) that is expected to return a Message object storing the value of text argument.

HackerRank Messages Order in C++ problem solution

HackerRank Messages Order in C++ problem solution

class Message {
public: 
    Message() {}
    Message(const string& text, int id) : text_(text), id_(id) {}
    const string& get_text() {
        return text_;
    }
    bool operator<(const Message& rhs) const {
        return this->id_ < rhs.id_;
    }
private:
    string text_;
    int id_;
};

class MessageFactory {
public:
    MessageFactory() {}
    Message create_message(const string& text) {
        return Message(text, current_id++);
    }
private:
    int current_id = 0;
};