Can operator= may be not a member?
Posted
by atch
on Stack Overflow
See other posts from Stack Overflow
or by atch
Published on 2010-03-31T18:35:17Z
Indexed on
2010/03/31
18:43 UTC
Read the original article
Hit count: 506
c++
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?
© Stack Overflow or respective owner