Having construction in a form:
struct Node
{
Node():left_(nullptr), right_(nullptr)
{ }
int id_;
Node* left_;
Node* right_;
};
I would like to enable syntax:
Node parent;
Node child;
parent.right_ = child;
So in order to do so I need:
Node& operator=(Node* left, Node right);
but I’m getting msg that operator= has to be a member fnc; Is there any way to circumvent this restriction?
An automatic conversion from value to pointer creates lots of possibilites to make your code hard to understand.
If you still want to do it you can provide a conversion operator on your Node class: