C++ reference deleted function error -


void user::addaccount(const account& _account) { this->account = _account; } 

is giving me error, as

void user::adddevice(const device& _device){ this->device = _device; }

does not give error. error is

severity code description project file line suppression state error c2280 'account &account::operator =(const account &)': attempting reference deleted function

i have used same construct , error

you need overload = operator able this.

  • see, when type x = y in code , if both of same type , compiler(provided not using interpreted language) knows how assign them work fine.

  • now account custom type, have tell c++ compiler how assign them.

device class/structure have overloaded it. quite simple example same check out

link tutorialpoint = operator overloading


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -