19.13.  Review Questions

[ fromfile: types-questions.xml id: types-questions ]

  1. What is the difference between a statement and an expression?

      An expression has a type and a value. A statement is just something to be executed. Statements are grouped with {} while expressions are grouped with the ().

  2. What is the difference between an overloaded operator and a function?

      All averloaded operators have corresponding function definitions. In fact, it is possible to invoke operators using the function call syntax. Therefore, operators are just syntactic shorthand for certain functions.

  3. What ways can you introduce a new type into C++?

      class, struct, enum, typedef

  4. Which cast operator is best suited for numeric values?

      static_cast

  5. What happens when you assign an int variable to a double value?

  6. Which cast operator is best suited for downcasting through polymorphic hierarchies?

      dynamic_cast

  7. Why are ANSI casts preferred over C-style casts?

  8. What is a situation that you might find the reinterpret_cast used in a reasonable way?