Click here to Skip to main content
15,907,233 members
Home / Discussions / ATL / WTL / STL
   

ATL / WTL / STL

 
GeneralRe: multithreading deque<> question Pin
geo_m6-Nov-03 5:26
geo_m6-Nov-03 5:26 
GeneralRe: multithreading deque<> question Pin
valikac6-Nov-03 5:51
valikac6-Nov-03 5:51 
GeneralRe: multithreading deque<> question Pin
Jeff Varszegi6-Nov-03 6:47
professionalJeff Varszegi6-Nov-03 6:47 
GeneralRe: multithreading deque<> question Pin
wibbik6-Nov-03 20:20
wibbik6-Nov-03 20:20 
GeneralRe: multithreading deque<> question Pin
Giles9-Nov-03 10:55
Giles9-Nov-03 10:55 
GeneralLinker error for vtMissing Pin
nigs_krec6-Nov-03 2:32
nigs_krec6-Nov-03 2:32 
GeneralRe: Linker error for vtMissing Pin
Brian Shifrin6-Nov-03 7:47
Brian Shifrin6-Nov-03 7:47 
General<vector> question Pin
Steve Messer5-Nov-03 7:02
Steve Messer5-Nov-03 7:02 
I am brand new to STL so please bear with me. I am creating an item Label based on an abstract class button. In code in the first segment works for me as expected. But In the second part I was not expected to have to cast (delete (Label*)pB; ) as noted below. When I don't cast the destuctor does not get called.

So, finally my question. As I am going thru the vector should I have to know each type of thing being deleted so I can cast it accordingly or am I approaching this all wrong?

In my application I was only using ( delete pB; ) and this is causing a memory leak. The only solution I see during clean up I query each object being destroyed for its type then call the appropriate code.

for example

if( objecttype == Label )
delete (Label*)pButton;
else if ( objecttype == Image )
delete (Image*)pButton;

This seems wrong to me. Please enlighten me.


// First part of code example
std::vector<Button*> vButtons;

pButton = new Label( ... );
vButtons.push_back( pButton );


// Second part of code example
int count = vButtons.size();

if( count > 0 )
{
std::vector<Button*>::iterator it;
Button *pB;
for (it = vButtons.begin(); it != vButtons.end(); ++it)
{
pB = *it;
if(pB != NULL)
{
delete (Label*)pB;
pB = NULL;
}
}
vButtons.clear();
}
GeneralRe: <vector> question Pin
John M. Drescher5-Nov-03 7:17
John M. Drescher5-Nov-03 7:17 
GeneralRe: <vector> question Pin
Steve Messer5-Nov-03 7:59
Steve Messer5-Nov-03 7:59 
GeneralRe: &lt;vector&gt; question Pin
John M. Drescher5-Nov-03 8:08
John M. Drescher5-Nov-03 8:08 
GeneralRe: &lt;vector&gt; question Pin
Steve Messer5-Nov-03 8:15
Steve Messer5-Nov-03 8:15 
GeneralConvert habdle to object pointer Pin
abhay1013-Nov-03 18:55
abhay1013-Nov-03 18:55 
GeneralRe: Convert habdle to object pointer Pin
Abhishek Srivastava3-Nov-03 22:32
Abhishek Srivastava3-Nov-03 22:32 
GeneralRe: Convert habdle to object pointer Pin
abhay1014-Nov-03 19:02
abhay1014-Nov-03 19:02 
GeneralRe: Convert habdle to object pointer Pin
Steve S3-Nov-03 22:44
Steve S3-Nov-03 22:44 
GeneralRe: Convert handle to object pointer Pin
BobAshforth17-Dec-03 7:10
BobAshforth17-Dec-03 7:10 
GeneralProblem with GUID Pin
Gabriel.P.G3-Nov-03 16:35
Gabriel.P.G3-Nov-03 16:35 
GeneralRe: Problem with GUID Pin
umeca743-Nov-03 21:24
umeca743-Nov-03 21:24 
GeneralRe: Problem with GUID Pin
Gabriel.P.G4-Nov-03 5:57
Gabriel.P.G4-Nov-03 5:57 
Generaliterator. Pin
WREY3-Nov-03 12:46
WREY3-Nov-03 12:46 
GeneralRe: iterator. Pin
Michael Dunn3-Nov-03 16:56
sitebuilderMichael Dunn3-Nov-03 16:56 
GeneralRe: iterator. Pin
WREY3-Nov-03 17:55
WREY3-Nov-03 17:55 
GeneralRe: iterator. Pin
Stuart Dootson3-Nov-03 21:13
professionalStuart Dootson3-Nov-03 21:13 
GeneralRe: iterator. Pin
ZoogieZork3-Nov-03 19:01
ZoogieZork3-Nov-03 19:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.