Static Cast

This is the simplest type of cast that can be used. It is a compile-time cast. It does things like implicit conversions between types (such as int to float, or pointer to void*), and it can also call explicit conversion functions.

static_cast in C++

A Cast operator is a unary operator which forces one data type to be converted into another data type.

C++ supports 4 types of casting:

This article focuses on discussing the static_cast in detail.

Similar Reads

Static Cast

This is the simplest type of cast that can be used. It is a compile-time cast. It does things like implicit conversions between types (such as int to float, or pointer to void*), and it can also call explicit conversion functions....

Syntax of static_cast

static_cast (source);...

Example of static_cast

Below is the C++ program to implement static_cast:...

The behavior of static_cast for Different Scenarios

...

Contact Us