Okay I'm reading a book that is talking about copying data from a previous class object into another class object. In this tutorial they're trying to teach me to use a pointer as the temporary object to copy the original class object. The only problem is, they never initialized the pointer... Can you do that? I thought that you always had to initialize and assign the pointer to a variable, but they never did that. Also, I don't get how they're able to copy the object data with another object because of the " Counter operator++()" function, can someone please give me some insight on that as well?
int* x; //points to random memory, probably not yours
As for the pre-increment operator, they are returning a const Counter&, based off *this. Then on line 40, they are copying it into a new Counter using the compiler provided copy ctor.