How can the assignment from int to object be possible in C++?
问题 class phone { public: phone(int x) { num = x; } int number(void) { return num; } void number(int x) { num = x; } private: int num; }; int main(void) { phone p1(10); p1 = 20; // here! return 0; } Hi, guys Just I declared a simple class like above one. After that I assigned int value to the object that class, then it worked! (I printed its value. It was stored properly) If there is not a construct with int parameter, a compile error occurred. So, I think it's related with a constructor. Is that