Hi, its been a while since I've used CodeProject. Quick Question. I'm training myself on standard algorithms and trying to create a linked list. In Java it's easy.
class Node{
public int data;
public Node next;
public Node(int val){ data= val; next = null;}
}
In the C++ Pre Ox11 you could use raw pointers.
struct Node{
int data;
Node* next;
Node(int val):data(val),next(0){}
}
but you had to new up your next node and delete it afterwards. With the new version of C++, you can use unique_ptr. But if I try to use that, I can't seem to get a good node to next.
struct node{
int data;
unique_ptr next;
node(int al):data(val),next(nullptr){}
}
node a(3);
node b(4);
a.next = b; // Error
a.next = move(b); // Error
a.next.reset (b); // Error
Please could you enlighten me, on how I can get this to work. Many Thanks Tom