Ok, let me start over.
I've managed to create a list of objects, as follows:
Code:
#include <iostream>
#include <cstdio>
#include <string>
#include "List.h"
using namespace std;
template<class User> class List;
class User
{
private:
// a list inside the user object, containing all of its interests
List<string> listInterest;
string name;
public:
User() {}
~User() {}
};
int main()
{
List<User> listUser;
listUser.add(User());
return 0;
}
That works fine, and what I'm doing there is adding an object user to the main user list.
Now this is what I'm trying to get right:
I want to be able to identify the user object within the user list by its name, that way I know whether the user exists or not.
So my question is: is it possible to add an object to the list identified by its name?
like
Code:
listUser.add(User(name));
I know that it won't work, I have to assign its name in the constructor, but as an example so I'm clear on what I'm trying to create.
Thank you.