Meadville Space Center

Project Apollo - NASSP => Programming => Topic started by: movieman on January 15, 2008, 01:27:36 PM

Title: Casts
Post by: movieman on January 15, 2008, 01:27:36 PM
BTW, I've started changing casts in the code from C-style to C++-style when I spot one; it makes them easier to find in a search if you think something might be screwing up, and means you have to think slightly more about what you're doing when you make the cast (e.g. it won't cast from const to non-const unless you use const_cast, whereas C-style casts don't care).

In theory we can also use type-safe casts, but I don't know if they'll work when the code is in multiple DLLs; I think it uses the address of the virtual function table to determine the type.

We should probably start adding 'const' in appropriate places too, when things aren't meant to change.

Title: Re: Casts
Post by: lassombra on January 15, 2008, 01:40:04 PM
I totally agree.  Though there is also the other side of things, using const when you have to change it.  Caused me more than a few headaches this morning when I couldn't figure out why my code wouldn't compile.  Had thrown in an accidental const in a method definition.