Search⌘ K

Type-Casting

Explore type-casting in C++ to convert data between types. Learn how implicit casting lets the compiler manage conversions and how explicit casting enables manual control. Understand data loss risks and conversion hierarchy to write accurate and efficient C++ programs.

Introduction

Suppose you have initialized a variable with a char data type. At some point in a program, you need its integer value. In such situations, type-casting comes in.

Type-casting is a way to convert the value of one data type to another data type.

Types of type-casting

Type-casting has two types:

  • Implicit casting
  • Explicit casting
...