Skip to main content
GameDev.net gamedev.net
๐Ÿ”’ Locked

I've a question!

Started by backstab Dec 4, 2001 at 8:14 AM 0 replies 350+ views
Original Post
backstab
backstab
Hi, What kind of problem can occur if delete [this] class instance by call member function of another class? -------------------------------------------------------------- Example: void CUser::ChangeTool (Tool * pNewTool) { delete this->pToolInUse ; // CTool * pToolInUse ; this->pToolInUse = pNewTool ; } and use the function above like this: void CTool::ToolBroken () { this->pUser->ChangeTool (new CTool) ; // CUser * pUser ; // pUser->pToolInUse refers [this] } -------------------------------------------------------------- What is the potential problem? Any suggestions? I''ve no problem yet...
Legacy of Ultima
Shannon Barber
Shannon Barber
You should make certain that the pNewtool pased in is NOT the pToolInUse (big-bada-boom)

If it''s a multi-threaded environment there''s syncronization issues.





Magmai Kai Holmlor
- Not For Rent
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.