Click here to Skip to main content
15,893,161 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: casting stl::vector confusion... [modified] Pin
yeti1115-Jan-07 18:21
yeti1115-Jan-07 18:21 
GeneralRe: casting stl::vector confusion... Pin
Stephen Hewitt15-Jan-07 18:27
Stephen Hewitt15-Jan-07 18:27 
GeneralRe: casting stl::vector confusion... Pin
yeti1115-Jan-07 18:39
yeti1115-Jan-07 18:39 
GeneralRe: casting stl::vector confusion... Pin
Stephen Hewitt15-Jan-07 18:43
Stephen Hewitt15-Jan-07 18:43 
GeneralRe: casting stl::vector confusion... Pin
yeti1115-Jan-07 18:44
yeti1115-Jan-07 18:44 
AnswerRe: casting stl::vector confusion... Pin
John R. Shaw15-Jan-07 4:18
John R. Shaw15-Jan-07 4:18 
GeneralRe: casting stl::vector confusion... Pin
yeti1115-Jan-07 12:09
yeti1115-Jan-07 12:09 
GeneralRe: casting stl::vector confusion... Pin
John R. Shaw19-Jan-07 16:23
John R. Shaw19-Jan-07 16:23 
Better late than never!

1) It overly complicates a simple operation and any methods available in the base class are also available in the derived class, unless the base class was declared private; in which case I would hope the complier rejects it. The idea is to find the simplest overall solution to a problem, making it easier to understand and implement. Except in a very narrow niche, this type of conversion should be avoided as it can introduce unexpected side effects.

2) Well that was a bit of an over statement. I can see thinking about it, but my mind automatically rejects that line of thought as anything more than a means to better understand the language.

If you need to store pointers to the derived class in a vector, other than a vector of base class pointers, then use dynamic_cast to convert the individual pointers on a per pointer bases, as needed. I do feel though that if you need to do this, then there is a fundamental flaw in the design.


INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra

QuestionA Qestion on thread Pin
sunshine jeffrey14-Jan-07 15:35
sunshine jeffrey14-Jan-07 15:35 
AnswerRe: A Qestion on thread Pin
Stephen Hewitt14-Jan-07 15:43
Stephen Hewitt14-Jan-07 15:43 
GeneralRe: A Qestion on thread [modified] Pin
sunshine jeffrey14-Jan-07 16:29
sunshine jeffrey14-Jan-07 16:29 
GeneralRe: A Qestion on thread Pin
Stephen Hewitt14-Jan-07 16:49
Stephen Hewitt14-Jan-07 16:49 
GeneralRe: A Qestion on thread Pin
sunshine jeffrey14-Jan-07 16:52
sunshine jeffrey14-Jan-07 16:52 
GeneralRe: A Qestion on thread Pin
Stephen Hewitt14-Jan-07 16:56
Stephen Hewitt14-Jan-07 16:56 
AnswerRe: A Qestion on thread Pin
Roger Stoltz14-Jan-07 20:30
Roger Stoltz14-Jan-07 20:30 
AnswerRe: A Qestion on thread Pin
Cristian Amarie14-Jan-07 23:35
Cristian Amarie14-Jan-07 23:35 
AnswerRe: A Qestion on thread Pin
David Crow15-Jan-07 3:44
David Crow15-Jan-07 3:44 
QuestionI don't know How to build Pin
rockfanskid14-Jan-07 15:34
rockfanskid14-Jan-07 15:34 
AnswerRe: I don't know How to build Pin
Nibu babu thomas14-Jan-07 17:42
Nibu babu thomas14-Jan-07 17:42 
QuestionRe: I don't know How to build Pin
David Crow15-Jan-07 3:46
David Crow15-Jan-07 3:46 
QuestionTimer + Network Programming = problem Pin
Sean Cleary14-Jan-07 13:07
Sean Cleary14-Jan-07 13:07 
AnswerRe: Timer + Network Programming = problem [modified] Pin
bob1697214-Jan-07 13:50
bob1697214-Jan-07 13:50 
AnswerRe: Timer + Network Programming = problem Pin
Mark Salsbery14-Jan-07 13:57
Mark Salsbery14-Jan-07 13:57 
GeneralRe: Timer + Network Programming = problem Pin
Sean Cleary15-Jan-07 11:39
Sean Cleary15-Jan-07 11:39 
AnswerRe: Timer + Network Programming = problem Pin
Mark Salsbery14-Jan-07 14:24
Mark Salsbery14-Jan-07 14:24 

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.