delete pointers in a vector

Started by
11 comments, last by Verg 18 years, 9 months ago
Thanks for the help. I added that code, stepped through my code and saw that it was doing the delete properly, thanks Verg. But it still gives me an error when I close the window.

Here is the code a commented to get a clean exit.
void Shape::CreateType1(void){	m_bIsActive = true;	float XAdd = 33.3f;	Block *newBlock1 = new Block(m_pD3DDevice, m_txtBlueBlock->GetTexture());	/*Block *newBlock2 = new Block(m_pD3DDevice, m_txtBlueBlock->GetTexture());	Block *newBlock3 = new Block(m_pD3DDevice, m_txtBlueBlock->GetTexture());	Block *newBlock4 = new Block(m_pD3DDevice, m_txtBlueBlock->GetTexture());	Block *newBlock5 = new Block(m_pD3DDevice, m_txtBlueBlock->GetTexture());	newBlock1->SetAbsoluteTranslation(START_OFFSET_X, START_OFFSET_Y, 0.0f);	newBlock2->SetAbsoluteTranslation(START_OFFSET_X + XAdd, START_OFFSET_Y, 0.0f);	XAdd += 33.3f;	newBlock3->SetAbsoluteTranslation(START_OFFSET_X + XAdd, START_OFFSET_Y, 0.0f);	XAdd += 33.3f;	newBlock4->SetAbsoluteTranslation(START_OFFSET_X + XAdd, START_OFFSET_Y, 0.0f);	XAdd += 33.3f;	newBlock5->SetAbsoluteTranslation(START_OFFSET_X + XAdd, START_OFFSET_Y, 0.0f);*/	/*m_smgr->Add(newBlock1);	m_smgr->Add(newBlock2);	m_smgr->Add(newBlock3);	m_smgr->Add(newBlock4);	m_smgr->Add(newBlock5);*/	/*m_Blocks.push_back(newBlock1);	m_Blocks.push_back(newBlock2);	m_Blocks.push_back(newBlock3);	m_Blocks.push_back(newBlock4);	m_Blocks.push_back(newBlock5);*/	newBlock1->Shutdown();  //NEW	delete newBlock1;        }


If I take that part out of the local method it gives me the error. So I push it back into the vector and call that Delete() class, it deletes it but it still comes back with the error. I am going crazy. If you would like me to post my whole game code, library and all. Let me know, because I cannot figure this out for the life of me.

If you insist on saying "DUH", try to make a post that makes a little more sense
Advertisement
Hey I tried my code on my home computer and it works just fine. Also I think I turned up all the errors on my other computer at work on the compiler. Could it just be different computers or memory leaks. Is it good to turn up all the error messages to get every last error fixed or is it just overkill trying to fix an error that doesn't exist.
If you insist on saying "DUH", try to make a post that makes a little more sense
Don't know what to tell you. If it works at home, but not at work or school, or wherever it is... it could be you need to clean/rebuild the project on the away computer.

From what it sounds like, the problem isn't related to creating or deleting blocks... it's likely elsewhere.
my_life:          nop          jmp my_life
[ Keep track of your TDD cycle using "The Death Star" ] [ Verge Video Editor Support Forums ] [ Principles of Verg-o-nomics ] [ "t00t-orials" ]

This topic is closed to new replies.

Advertisement