Messages Order

  • + 1 comment
    class Message {
    private:
        string s;
        int order;
    public: 
        Message(const string& text, int Order) {
            s = text;
            order = Order;
        }
        const string& get_text() {
            return s;
        }
        bool operator < (const Message& second) {
            return order < second.order;
        }
    };
    
    class MessageFactory {
    public:
        static int counter;
        MessageFactory() {}
        Message create_message(const string& text) {
            Message temp(text, counter);
            counter++;
            return temp;
        }
    };
    
    int MessageFactory::counter = 1;