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

C / C++ / MFC

 
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 
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 
yeti11 wrote:
What is wrong with casting vector holding pointers?


Nothing, "per se" the problem with pointers is it is simply easier to make "unsafe code" which means the chances of a small bug like this one, are increased significantly above other alternatives. The reason for the alternatives is that you can spend a week tracking down this one bug, or another one, simply because the pointers give you the freedom to shoot yourself in the foot. It isn't the pointers fault really, a pointer is simply power, of course there is the ultimate power phrase, which applies to other pointer problems, but not this one. This is why you hear so many people say "no pointers, don't do this" and it isn't because it "cannot be done" it is because "the chances increase for error." You spend more time debugging than you do writing the code, time/money lost, etc. That is the primary reason to avoid pointers.

You can eventually figure this out, and we can all toss you out a hundred "small" errors that could be causing the problem. You'd probably get twice the number of suggestions from running something like PC-Lint on the code. Eventually one will be right. You find it, fix it, and all is okay. But the reason why folks are discouraging the pointer use, is because of the great number of "little" things that can go wrong.

We don't know your code, you do. You can't post all of your code, from the idea of IP and also space, so all any of us can do is generalize, offer some suggestions. But the primary reason folks are telling you to avoid the pointers is because it just increases the chance for these bugs. Generally speaking there is absolutely nothing wrong with pointers, pointers are good, pointers are powerful, and good written code with pointers works very well. It's just harder to get there, or find problems like this.

I've written programs with pointers, I've multi-threaded pointers, I have done near every great thing in the book with pointers. I have also made every mistake in the book with pointers. I use alternatives as often as possible, even in multi-object node storage, such as graphical scene graphs, which are my business.

Obviously I am not helping, so I will wish you well. I hope you find it and soon. Good luck in this and everything else.
Jeff

_________________________
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
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 
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 

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.