4 ms·
Assuming OP was talking about overloading the '=' operator: struct A { int *p = nullptr; A& operator=(int i) { *p = i; return *this;
by moefh 8y ago
Assuming OP was talking about overloading the '=' operator:
struct A {
int *p = nullptr;
A& operator=(int i) {
*p = i;
return *this;
}
};
int main(void)
{
A a;
a = 1; /* boom! */
return 0;
}