Maybe you can study something about basic data structures, like array, heap, binary tree, linked list.. I recommend you to read essays on www.aihorizon.com or maybe you can find something on this site.
If you want to have a linked list, for example
Code:
class List {
private:
Node *root;
Node *end;
public:
List(void) { root = end = NULL; };
void add(int value);
}
void List::Add(int value)
{
if (root == NULL) {
end = root = new Node;
end->data = value;
end->next = NULL;
return;
}
end->next = new Node;
end = end->next;
end->data = value;
end->next = NULL;
}
every node should be something like
Code:
class Node {
private:
int data;
Node *next;
friend class List;
}
This code is not optimal, you can make it shorter and more efficient and so. Just study some materials and practise...