casting operator in c++ code example
Example 1: casting C++
int main()
{
short a = 2000;
int b;
b = (int)a; // c-like cast notation
b = int(a); // functional notation
}
Example 2: c++ casting
static_cast<int>(some_double);
Example 3: how to static_cast
struct B { };
struct D : B { };
D d;
B& br = d;
static_cast<D&>(br); // lvalue denoting the original d object