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

C / C++ / MFC

 
Questioncasting stl::vector confusion... Pin
yeti1114-Jan-07 19:59
yeti1114-Jan-07 19:59 
AnswerRe: casting stl::vector confusion... Pin
Stephen Hewitt14-Jan-07 20:24
Stephen Hewitt14-Jan-07 20:24 
GeneralRe: casting stl::vector confusion... [modified] Pin
yeti1114-Jan-07 21:03
yeti1114-Jan-07 21:03 
AnswerRe: casting stl::vector confusion... Pin
El Corazon14-Jan-07 20:46
El Corazon14-Jan-07 20:46 
GeneralRe: casting stl::vector confusion... [modified] Pin
yeti1114-Jan-07 21:05
yeti1114-Jan-07 21:05 
AnswerRe: casting stl::vector confusion... Pin
Michael Dunn14-Jan-07 22:17
sitebuilderMichael Dunn14-Jan-07 22:17 
GeneralRe: casting stl::vector confusion... [modified] Pin
yeti1114-Jan-07 22:59
yeti1114-Jan-07 22:59 
GeneralRe: casting stl::vector confusion... Pin
El Corazon15-Jan-07 4:59
El Corazon15-Jan-07 4:59 
yeti11 wrote:
i dont want to loose general usage of library and coupling it with like 15 classes
that have nothing to do with it and... well it would be a mess.


Not necessarily. You can hide the 15 classes within design patterns based on construction and/or behavior as appropriate to the 15 classes. The example given in Wikipedia is a very common one for a bridge, every object class for computer drawing has a "draw" function, at the far end the draw() is generic, you don't care what is being drawn, the information held within allows you to draw almost any shape and add more shapes.

http://en.wikipedia.org/wiki/Bridge_pattern[^]

look at the C++ code for drawing Circles and Squares from the same "shape" class. Is this the type of generic bridge you are trying to accomplish?


yeti11 wrote:
i want to understand what i am doing wrong and why


without actually seeing your code, I can't tell you where the error lies for sure. The design via pointers is dangerous because of the STL habit of automatically changing its memory structure. Also pointers are not always held constant between threads, depending on when the pointers are built, and assigned the memory may not be shared between threaded operation calls.

Which brings us back to generic classes to hide implementation. Bridges or Composites[^] and building with other abstraction classes such as Builder[^]

Take a look through the gang-of-four Design Patterns[^] and see if one of those is what you are trying to achieve.

_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)

GeneralRe: casting stl::vector confusion... Pin
yeti1115-Jan-07 11:57
yeti1115-Jan-07 11:57 
GeneralRe: casting stl::vector confusion... Pin
El Corazon15-Jan-07 15:00
El Corazon15-Jan-07 15:00 
GeneralRe: casting stl::vector confusion... Pin
Stephen Hewitt15-Jan-07 12:37
Stephen Hewitt15-Jan-07 12:37 
GeneralRe: casting stl::vector confusion... Pin
Stephen Hewitt15-Jan-07 12:02
Stephen Hewitt15-Jan-07 12:02 
GeneralRe: casting stl::vector confusion... Pin
yeti1115-Jan-07 12:16
yeti1115-Jan-07 12:16 
GeneralRe: casting stl::vector confusion... Pin
Stephen Hewitt15-Jan-07 16:00
Stephen Hewitt15-Jan-07 16:00 
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 
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 

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.