a) Create a data structure, UserStore (.h) to store User objects, with the following features:
Given this User class:
class User
{ public:
User(int id, string name) : m_id(id), m_name(name) {}
int getId() const { return id; }
string getName() const { return name; }
virtual ~User() {}
// You may also assume overloaded operator= and copy constructor.
private: int m_id; string m_name; };
a) Create a data structure, UserStore (.h) to store User objects, with the following features:
● Method getUserById(int id), which returns the User with the given id, or nullptr if no such user exists.
● Method addUser(User user), which adds a new user to the store.
● Method visitUsers(void visit(User&)) to visit each User in the store, calling the provided "visit" method, which runs in O(n) time where n is the number of users in the store

Step by step
Solved in 5 steps with 1 images









