Thursday, February 11, 2010

Some more C++ tips

  • static_cast converts expression to the type of type-id based solely on the types present in the expression whereas dynamic_cast converts the operand expression to an object of type type-id.

  • Direct dereferencing of void pointer is not permitted. The programmer must change the pointer to void as any other pointer type that points to valid data types such as, int, char, float and then dereference it.

  • Pointer to void, or a void pointer, is a special type of pointer that has a great facility of pointing to any data type.

  • practical use of reinterpret_cast is in a hash function, which maps a value to an index in such a way that two distinct values rarely end up with the same index.

  • The reinterpret_cast operator is the least secure of the C++ typecasting operators.

  • The result of a const_cast expression is an rvalue unless Type is a reference type.

  • A const_cast operator is used to add or remove a const or volatile modifier to or from a type.

No comments:

Post a Comment