[Home]
[Edit this page]
[Recent Changes]
[Special Pages]
[Help]
CppStaticCast
Avoid using static_cast on pointers [1]. Don't use C-style casts [2].
Other casts are:
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
CppStaticCast
(C++) static_cast
The C++ way of converting (also: casting) a simple datatype to another:const int myInt = 10; const double myDouble = static_cast<double>(myInt);
Avoid using static_cast on pointers [1]. Don't use C-style casts [2].
Other casts are:
- const_cast, for casting away const
- dynamic_cast, for casting between related classes
- reinterpret_cast, for casting between unrelated data types
References
- 1) Herb Sutter and Andrei Alexandrescu. C++ coding standards: 101 rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 93: 'Avoid using static_cast on pointers'
- 2) Herb Sutter and Andrei Alexandrescu. C++ coding standards: 101 rules, guidelines, and best practices. ISBN: 0-32-111358-6. Item 95: 'Don't use C-style casts'
[Edit this page] [Page history] [What links here] [Discuss this topic] [Printer Friendly]
