Thameera Senanayaka
Allion Technologies
int a = 5;
double b = a;
double d = 3.0;
int i = (int)d;
void func( void *data )
{
Image *img = static_cast< Image* >( data );
// ...
}
const char *name = "abc";
someFunction( const_cast< char* >( name ) );
void func( Image *img )
{
if( PngImage *png = dynamic_cast< PngImage* >( img ) )
{
}
else if( JpgImage *jpg = dynamic_cast< JpgImage* >( img ) )
{
}
}
long val = 0x12345cafebabe;
char *charPtr = reinterpret_cast< char* >( &val );
for( int i = 0; i < sizeof( long ); ++i )
{
std::cout << byteToHex( *charPtr ) << std::endl;
charPtr++;
}
C-style casts are dangerous because they can turn into reinterpret_casts