c++ - datatype pointers using *(datatype*) -


this question has answer here:

i started learn bit more c++ , lately see stuff (dword)(x+y);

example:

    int number = 10; int pointer;  pointer = *(int*)(number);  std::cout << "number: " << number << std::endl; std::cout << "pointer: " << pointer << std::endl;  getchar(); 

this makes exception, know, explain action me? (int) , (dword) etc.. or, recommend me book? thanks!

casting or type conversion changing variable 1 datatype another. there 2 types. implicit , explicit casting.

implicit type conversion, known coercion, automatic type conversion compiler.

double = 3.4; int b = a; //convert 'a' implicitly 'double' 'int' 

explicit type conversion type conversion explicitly defined within program

int = 3; double b = (int)a; //convert 'a' explicitly 'int' 'double' 

a dword 32-bit unsigned integer. i'ts type. pointer datatype.

void *a; int *b = (int*)a; //explicit void *c = b; //implicit 

about cating: https://en.wikipedia.org/wiki/type_conversion#implicit_type_conversion book recommendation: the definitive c++ book guide , list


Comments