Why does this script error? What's the correct way to write a boilerplate opAssign? (You can probably tell I'm not too experienced with C++.)
class MyClass {
int x;
MyClass(int x) {
this.x = x;
}
MyClass opAssign(const MyClass &c) {
x = c.x;
return this;
}
}
I tried adding an empty default constructor (MyClass() {}) and that made it compile but enter an infinite loop when opAssign is called. I don't want to have a default constructor (that means constructor with no arguments?), it doesn't make sense to have a default value for x in my domain.