int main()
{
short a = 2000;
int b;
b = (int)a; // c-like cast notation
b = int(a); // functional notation
}
static_cast<int>(some_double);
// 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 );
#include <iostream>
using namespace std;
int main(){
int x = 4;
int y = 2;
cout<<"La divisione dei valori e': "<<(float)y/x<<endl;
}
// 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 );