I am creating a stack with the following Attributes and I am trying to create a copy-constructor and an assignment-operator but I can't since the new object and the old one point to the same memory. Please assist.
class Node
{
public:
Node(const T& data, Node* n = 0)
{
element = data;
next = n;
}
T element;
Node* next;
};
/* The top of the stack */
Node* top;