In your example vector<Node> copy of your nodes will be stored, so t1 , t2 will be copied.
In addition, the default copy constructor for Node will make a shallow copy. Thus,
Node* head = new Node(); Node* next = new Node(); head->other_node = next; Node* other_head = new Node(*head);
*(other_head->other_node) is the same Node as *(head->other_node) . It is up to you to decide whether this behavior suits you.
As for destructors: you should remove or free the memory that the instance of the class provided, unless you have good reason to own the memory. In the case of your list, in general, since your list did not allocate the memory specified in other_node , it should not be deleted.
Efficiency, since your Node is fairly inexpensive to copy (int and pointer), keeping the copy in order. If your Node class made a deep copy, then it would be better in terms of performance to use vector<Node*>
source share