Why is the address of this volatile variable always at 1?
问题 I wanted to inspect the address of my variable volatile int clock; cout << &clock; But it always says that x is at address 1. Am i doing something wrong?? 回答1: iostreams will cast most pointers to void * for display - but no conversion exists for volatile pointers. As such C++ falls back to the implicit cast to bool . Cast to void* explicitly if you want to print the address: std::cout << (void*)&clock; 回答2: There's an operator<< for const void* , but there's no operator<< for volatile void*