Cannot assign to overloaded dereference (*) operator

c++, operator-keyword, overloading, pointers, templates

Solution

Just give it `T&` as the return type. Then you have an lvalue. The problem right now is that you're returning a copy of the object pointed to.

Problem

I have overloaded dereference operator for my template class: ``` template <class T> class Node { public: T *pointer; T operator*() { return *pointer; } }; ``` I want to be able to write to the pointer in main: ``` Node<int> n; *n = 33; ``` But I get this error: ``` lvalue required as left operand of assignment ``` How should I overload this operator to be able to write to the pointer?

Original source