Using a static_cast to Compile Narrowing Conversions - C++ Data Type

C++ examples for Data Type:Cast

Description

Using a static_cast to Compile Narrowing Conversions

Demo Code

int main()//from ww  w .j  av  a2 s  . c om
{
    int number{ 0 };
    char another{ static_cast<char>(512) };

    double bigNumber{ 1.0 };
    float littleNumber{ static_cast<float>(bigNumber) };

    return 0;
}

Related Tutorials