Originally Posted by
tabstop
1. The code
[code]
In myFunctionArgument, arg1 is constructed "during" the function call (i.e., before the flow of control is handed off to the function), then myObj is changed by the assignment operator, then arg1 is destructed before flow of control returns to the caller.
Thanks!! That was the answer I was looking for. So it seems passing objects without references is a much object-oriented and cleaner way of doing things. On the other hand, it's not very efficient.
In Java, function calls are passed by reference 1) to make things more efficient 2) elminate the confusion for the programmers.
Also yes I had a few typos. the myObj = new object_type would not have compiled. I meant to say this:
Code:
object_type myObj; //global delcaration because I need to initialize it within the case statement in WM_CREATE.
...
WM_CREATE:
object_type myObj= object_type(dcHandle);
It just occured to me that when I declare it, a copy was made. At the WM_CREATE, I have the object constructed it again. Yes one would argue that poniters would make things more efficient but I have to keep track of the dcHandle. Anyhow I'll just use pointers and add a destructor.