# Chapter 13 - Worked Exercises 1

## Exercise 1&#x20;

### Part 0 - Static Cast

1. What checks are imposed by the `static_cast` operator?
2. Is it at **compile time** or at **runtime** that these checks are performed?&#x20;
3. Will `static_cast` **always** return a value?
4. There are two scenarios where `static_cast` should be used, one related to inheritance, the other related to implicit type conversions. Describe these scenarios.&#x20;
5. What is **upcasting** and **downcasting**?&#x20;
6. When should you **not downcast** an object pointer?

### Part 1 - Dynamic Cast

1. How does `dynamic_cast` differ to that of `static_cast`?&#x20;
2. What is the result of invoking `dynamic_cast`?&#x20;
3. What is **runtime type identification**? Show a basic example illustrating this concept.&#x20;
4. Why should you always check for the return value of a `dynamic_cast` operation?&#x20;

### Part 2 - Reinterpret Cast&#x20;

1. What is the effect on the underlying value of a variable when performing a `reinterpret_cast` operation? How does it differ to that of implicit casting?&#x20;

### Part 3 - Const Cast

1. What is the purpose of const casting? Show a simple example of its usage.
2. Why should const cast only be used as a last resort? What alternatives should be explored before attempting to use a const cast?&#x20;

### Part 4 - Workshop

Please complete the Workshop section for Chapter 14 in the textbook (pg. 389).&#x20;
