Conversions using a Static_cast Syntax

Learn about the conversions using a static-cast syntax in the C++ language.

We'll cover the following

Problem

Write a program that carries out the following conversions using a static_cast syntax:

  1. cast-less conversions
  2. narrowing conversions
  3. conversions from void *
  4. implicit type conversions

Also, illustrate the use of reinterpret_cast.

Sample run

Here’s what you should see when you run the program.

10		10
0xfde8
0xfdec
65004
65005

Coding solution

Here is a solution to the problem above.

Note: You would see an error while executing this code.

Get hands-on with 1400+ tech skills courses.