-
Non-copyable object
Is this how I would make an object non-copyable:
Code:
class Node{
public:
T data;
Node *next, *prev;
Node(const T& d, Node* n = 0, Node* p = 0) : data(d), next(n), prev(p) {};
private:
Node(const Node& rhs_n) : data(rhs_n.data), next(rhs_n.next), prev(rhs_n.prev) {};
Node& operator=(const Node& rhs_n){
data = rhs_n.data;
next = rhs_n.next;
prev = rhs_n.prev;
return *this;
};
};
????
-
Well, yes. If the operator = and copy constructor is private, then no one can copy it. You don't need to implememt the functions, however.