#include using namespace std; int main() { unsigned ui = 0U; unsigned long ul = 123UL; int i = 0; bool b; float f = 3; // i = rand() % f; // Error i = rand() % static_cast(f); b = i < ul; // Warning b = static_cast(i) < ul; f = NULL; // Warning f = static_cast(NULL); enum color { red, white, blue }; // Assign int value to enum variable // color hue = 1; // Error color hue = static_cast(1); // Assign enum variable to int type i = hue; // OK // Assign enum value to int type ui = white; // OK int* ptrI; // ptrI = &f; // Error // ptrI = static_cast(&f); // Error ptrI = reinterpret_cast(&f); // OK }