Messages Order

  • + 0 comments
    class Message {
    public: 
        Message() {}
        
        Message (const string& m) : m_Id(s_Id++), m_Message(m) {}
        
        const string& get_text() {
            return m_Message;
        }
        
        bool operator<(const Message& toCompare)
        {
            return m_Id < toCompare.m_Id;
        }
        
        static int s_Id;
        private:
        int m_Id;
        string m_Message;
        
    };
    
    int Message::s_Id = 0;
    
    class MessageFactory {
    public:
        MessageFactory() {}
        Message create_message(const string& text) {
            return Message(text);
        }
    };``