Click here to Skip to main content
15,892,537 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Bjarne's member function binding sample is wrong? Pin
George_George10-Mar-08 19:05
George_George10-Mar-08 19:05 
AnswerRe: Bjarne's member function binding sample is wrong? Pin
David Crow10-Mar-08 3:34
David Crow10-Mar-08 3:34 
GeneralRe: Bjarne's member function binding sample is wrong? Pin
George_George10-Mar-08 3:43
George_George10-Mar-08 3:43 
Generalnon-dependent name in template function Pin
George_George9-Mar-08 16:10
George_George9-Mar-08 16:10 
GeneralVC++ MFC - getting started Pin
Fred Andres9-Mar-08 14:35
Fred Andres9-Mar-08 14:35 
GeneralRe: VC++ MFC - getting started Pin
Christian Graus9-Mar-08 19:45
protectorChristian Graus9-Mar-08 19:45 
GeneralRe: VC++ MFC - getting started Pin
David Crow10-Mar-08 3:43
David Crow10-Mar-08 3:43 
Questionvector.push_back, item disappears [modified] Pin
Anthony Mushrow9-Mar-08 14:26
professionalAnthony Mushrow9-Mar-08 14:26 
Right, well. I have a struct which so far contains just a char* and a vector of the struct.

Now, i have a function that adds a new item to my vector which takes a char* which is used to initialise my struct:

void AddItem(char* ItemName)
{
   myStruct newItem(ItemName);
   myVector.push_back(newItem);
}


In the struct constructor i used strcpy to copy the contents of the string rather than the pointer, and i also made a copy constructor which uses strcpy again when copying the struct.

But still, once we leave the function (or should i say, the function in which this function was called) the item, disappears. Debuging it i can see that the item is added and then once we get out of the functions simply vanishes, and i don't understand why.

So, any help of course, would be greatly appreciated.

My current favourite word is: Nipple!
-SK Genius


modified on Sunday, March 9, 2008 8:37 PM

GeneralRe: vector.push_back, item disappears Pin
Mark Salsbery9-Mar-08 14:42
Mark Salsbery9-Mar-08 14:42 
GeneralRe: vector.push_back, item disappears Pin
Anthony Mushrow9-Mar-08 14:56
professionalAnthony Mushrow9-Mar-08 14:56 
GeneralRe: vector.push_back, item disappears Pin
Mark Salsbery9-Mar-08 15:05
Mark Salsbery9-Mar-08 15:05 
GeneralRe: vector.push_back, item disappears Pin
Anthony Mushrow9-Mar-08 15:18
professionalAnthony Mushrow9-Mar-08 15:18 
GeneralRe: vector.push_back, item disappears Pin
Mark Salsbery9-Mar-08 15:31
Mark Salsbery9-Mar-08 15:31 
QuestionThe old story of "DEBUG vs RELEASE" Pin
Joseph Marzbani9-Mar-08 5:55
Joseph Marzbani9-Mar-08 5:55 
QuestionRe: The old story of "DEBUG vs RELEASE" Pin
CPallini9-Mar-08 6:16
mveCPallini9-Mar-08 6:16 
GeneralRe: The old story of "DEBUG vs RELEASE" Pin
john56329-Mar-08 21:32
john56329-Mar-08 21:32 
GeneralCopy constructor problem [modified] Pin
followait9-Mar-08 5:48
followait9-Mar-08 5:48 
GeneralRe: Copy constructor problem Pin
CPallini9-Mar-08 5:58
mveCPallini9-Mar-08 5:58 
GeneralRe: Copy constructor problem Pin
Rajkumar R9-Mar-08 20:26
Rajkumar R9-Mar-08 20:26 
GeneralStandalone EXE Pin
ddspliting9-Mar-08 4:21
ddspliting9-Mar-08 4:21 
GeneralOh, they made it again! Pin
CPallini9-Mar-08 5:50
mveCPallini9-Mar-08 5:50 
GeneralRe: Standalone EXE Pin
followait9-Mar-08 5:51
followait9-Mar-08 5:51 
GeneralRe: Standalone EXE Pin
ddspliting9-Mar-08 10:12
ddspliting9-Mar-08 10:12 
GeneralRe: Standalone EXE Pin
CPallini9-Mar-08 11:18
mveCPallini9-Mar-08 11:18 
GeneralRe: Standalone EXE Pin
followait9-Mar-08 15:49
followait9-Mar-08 15:49 

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.