Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Destructors

Status
Not open for further replies.

prout

Technical User
Apr 24, 2003
1
FR
I use my own Matrix class. A function returns a local Matrix-class object I've created in it("Matrix aa;"). But before returning it ("return aa;") the destructor is called and I return a void object. Then after the return operation the destructor is called again. I don't know why and I thought that the destructor is only called at the end of my function.
 
It seems like you are returning pointer to local object. The scope of local objects is inside of the function only, they all are destroyed during return from the function.
Use operator "new" for dynamicall allocation of the objects.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top