Answers for "cast type cpp"

C++
4

C++ Type Casting

float a = 10.3;
    int b;
    char c = 's'; //115 in ASCII

    //USING IMPLICIT TYPECASTING
    b = a / 2; //where the value of 'a' turned into int value 
    cout << b << endl;
    cout << b + c << endl;

    //USING EXPLICIT TYPECASTING
    cout << (int) a + 8 << endl;
Posted by: Guest on March-06-2022
1

c++ cast to type of variable

x = static_cast<decltype(x)>(y);
Posted by: Guest on November-25-2021
0

cast cpp

// conversion de int en char 
int i = 100; 
char c = static_cast<char>( i ); 
  
// conversion de float en int 
float f = 100.0f; 
i = static_cast<int>( f ); 
  
// conversion classes dérivée -> classe parent 
class A {}; 
class B : public A {}; 
  
B *b = new B; 
A *a = static_cast<A*>( b );
Posted by: Guest on February-16-2022

Browse Popular Code Answers by Language