help linked list of objects
Greetings from a newbie,
I'm currently working on a project similar to facebook but way simpler using a command line interface. The user is able to create an account and he/she is entitled to add interests and create friendships with other users.
The main algorithm that I developed is based upon an object which is the user and its attributes are the functions that add interests, friends, so on.
Users are stored in a linked list while their interests are stored in another list.
What I want to do is every time a new user is created, add that user to the list and create a new list containing the user's personal info. In other words, create a list of objects.
This is a sample of the algorithm I've thought of:
Code:
#include <iostream>
#include <cstdio>
#include <string>
#include "List.h"
using namespace std;
template<class User> class List;
class User
{
private:
string name;
List<string> listInterest;
public:
User() {}
List<string> listUser;
void setName(string name);
~User() {}
};
void User::setName(string name)
{
listUser.add(User(name));
}
int main()
{
User U;
U.setName("Jane");
return 0;
}
As you can see I get a compilation error that I don't understand: "no matching function for call to 'User::User()'
Is someone willing to give me a hint? Just so I get on the right track.
I would highly appreciate it. Thank you!