Click here to Skip to main content
15,908,776 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionDangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa14-Dec-08 20:02
Mustafa Ismail Mustafa14-Dec-08 20:02 
AnswerRe: Dangling pointers and incorrect data being written Pin
Cedric Moonen14-Dec-08 20:48
Cedric Moonen14-Dec-08 20:48 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa14-Dec-08 21:11
Mustafa Ismail Mustafa14-Dec-08 21:11 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson14-Dec-08 21:31
professionalStuart Dootson14-Dec-08 21:31 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa14-Dec-08 21:42
Mustafa Ismail Mustafa14-Dec-08 21:42 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson14-Dec-08 22:07
professionalStuart Dootson14-Dec-08 22:07 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa15-Dec-08 1:43
Mustafa Ismail Mustafa15-Dec-08 1:43 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson15-Dec-08 13:37
professionalStuart Dootson15-Dec-08 13:37 
I'm a f**king idiot. I've built your code and stepped through it with GDB (well, Xcode on my Mac) and just realised what the problem is, when it should have been immediately obvious.

The trouble is your copy constructors - they're not doing anything! Which means that as they're used when copying items into a vector using push_back, the vector gets set with empty items.

Anyway - you can rely on the default copy constructor and assignment operator if member-wise copy is adequate for your structure. Member-wise is fine unless you need to do some sort of resource management (e.g. memory allocation/deallocation).

Hope that sorts you out!
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa16-Dec-08 18:21
Mustafa Ismail Mustafa16-Dec-08 18:21 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson16-Dec-08 19:40
professionalStuart Dootson16-Dec-08 19:40 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa16-Dec-08 19:50
Mustafa Ismail Mustafa16-Dec-08 19:50 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson16-Dec-08 21:52
professionalStuart Dootson16-Dec-08 21:52 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa16-Dec-08 23:50
Mustafa Ismail Mustafa16-Dec-08 23:50 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson17-Dec-08 2:34
professionalStuart Dootson17-Dec-08 2:34 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa17-Dec-08 4:47
Mustafa Ismail Mustafa17-Dec-08 4:47 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson17-Dec-08 5:18
professionalStuart Dootson17-Dec-08 5:18 
GeneralRe: Dangling pointers and incorrect data being written [modified] Pin
Mustafa Ismail Mustafa17-Dec-08 5:52
Mustafa Ismail Mustafa17-Dec-08 5:52 
GeneralRe: Dangling pointers and incorrect data being written Pin
Stuart Dootson17-Dec-08 6:25
professionalStuart Dootson17-Dec-08 6:25 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa17-Dec-08 6:35
Mustafa Ismail Mustafa17-Dec-08 6:35 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa14-Dec-08 21:12
Mustafa Ismail Mustafa14-Dec-08 21:12 
GeneralRe: Dangling pointers and incorrect data being written Pin
Mustafa Ismail Mustafa14-Dec-08 21:26
Mustafa Ismail Mustafa14-Dec-08 21:26 
QuestionDevelop CSP in XP Pin
izyani14-Dec-08 19:48
izyani14-Dec-08 19:48 
QuestionUsing Queue Timers...... Pin
shaina223114-Dec-08 19:22
shaina223114-Dec-08 19:22 
AnswerRe: Using Queue Timers...... Pin
Sarath C15-Dec-08 2:16
Sarath C15-Dec-08 2:16 
AnswerRe: Using Queue Timers...... Pin
Mark Salsbery15-Dec-08 11:27
Mark Salsbery15-Dec-08 11:27 

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.