So temporary objects are always const, which is something I didn't know. Thanks :D
Type: Posts; User: Mr.Pointer
So temporary objects are always const, which is something I didn't know. Thanks :D
Whoops, I'm really sorry, I wrote a bad example! What I meant to write was something like this:
Number a = 20;
a = 40;
The constructor is indeed called twice, and your explanation makes a lot of...
Like I said, this happens when I remove the copy assignment operator, and when the class doesn't have an assignment operator for an int, it calls the constructor.
I decided to start an extremely simple experiment to revise on things I already know, but came across two things that puzzled me. I have a class named Number, which only holds an integer named...