user p ;
p.name = "ted";
p.id =12;
node<user> *head_ptr;
node<user> *tail_ptr;
node<user> r;
head_ptr = NULL;
tail_ptr = NULL;
I have tryed
head_ptr = p;
head_ptr is of type node<user>* and p is of type user so this assignment won't work as the types are really quite unrelated. You need to create a node<user>* in order to initialize head_ptr.
Something like:
template<typename T>
struct node
{
node(const T &data) : data(data), next(0) { }
T data;
node *next;
};
struct user
{
user(const std::string &name, int id) : name(name), id(id) { }
std::string name;
int id;
};
// ...
node<user> *p = new node<user>(user("ted", 12));
This is reasonably elementary-level stuff. If you're struggling with it, it might be worth picking up a beginners C++ text or reading through some tutorials.