User forums > Help

GetStockObject not working right?

<< < (2/3) > >>

sethjackson:

--- Quote from: thomas on February 06, 2006, 09:43:30 pm ---
--- Quote from: sethjackson on February 06, 2006, 09:37:42 pm ---DO NOT cast the way they suggested.  :P
static_cast, and it's friends are sooooo much better. :)

--- End quote ---
Casting is a hack anyway, so why make such a fuzz about it :P

--- End quote ---

True, but C-style casting is hard to spot (most of the time), and not as good.

http://public.research.att.com/~bs/bs_faq2.html#static-cast

Anyways avoid casting at all costs.  :D

Knyght:
I love you guys.

sethjackson:
Well I guess that means it works now.  :lol:

thomas:

--- Quote from: sethjackson on February 06, 2006, 09:48:55 pm ---True, but C-style casting is hard to spot (most of the time), and not as good.
--- End quote ---
What makes you think that it is "not as good"? It is really the same thing, except that you can do things like
--- Code: ---Foo *foo = new Foo;
Bar *bar = (Bar*) foo;
int a = (int) foo;
printf("%s", (const char*) a);
delete bar; // this one is especially good... :)
int b = 5;
wxWindow *c = (wxWindow*) b;
c->Show();

--- End code ---
with old-style C casts, which static_cast will of course not allow you to do.

However, static_cast's "friends" let you do such stuff, so if you want to shoot your foot, you can do it either way, and if you don't know what you're doing, you'll go to hell either way, too. :lol:

sethjackson:
:shock: That code sample.  :lol: :lol:

Anyways you are right it is the same thing. The C++ style casts are easier to spot however.  :)

In my case I'd rather not shoot myself at all.  :lol: :lol:

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version