How C++ Objects are referenced
Hello,
I have a class that is instantiated as follows:
Quote:
DCManager dcManager;
...
WM_CREATE:
dcManager= DCManager(dcImage);
It seems the compiler complaines that there's no default constructor when I use the following code "DCManager dcManager". This tells me that "DCManager dcManager" instantiates an instance during the declaration which is not I wanted.
Question 1. In my code above, an instance is created during the declaration, so in my WM_CREATE, another instance is created. That means the first instance is explictly deleted? That is, the default constructor is called when the dcManager=DCManager(dcImage) creates another instance?
Now, I have my code as follows:
Quote:
DCManager dcManager=NULL;
QueueHolder queueHolder=NULL;
...
WM_CREATE:
dcManager= DCManager(dcImage);
queueHolder = QueueHolder(dcManager);
Question 2: In the code above, is the dcManger passed as a reference or another copy is made when the queueHolder = QueueHolder(dcManager) is called?
Question 3: I want to debug to see if the deconstructor for the DCManager is coded correctly. Can I explictly use delete the dcManager instead of waiting for it to go out of scope:
Quote:
WM_CREATE:
dcManager= DCManager(dcImage);
queueHolder = QueueHolder(dcManager);
WM_DESTROY:
delete dcManager;
delete queueHolder;