I am wondering about the different uses of the volatile keyword in combination with register, const and static keywords. I am not sure what are the effects, so I think:
register volatile int T=10;
Suggest the compiler to store T in a register and the value of T can be modified from somewhere outside (OS, hardware, another thread)
const volatile int T=10;
The program itself can not modify T, but T can be modified frow somewhere outside the code.
static volatile int T=10;
If T is a data member of a class it means that all the objects of the class have the same value for T and T can be modified from somewhere outside. If T is a global variable in a file, the source code in other files (that are part of the project) cannot access T, but T can be accessed from somewhere outside. If T is a local variable in a function,once it has been initialized remains in the memory until the end of the program and can be modified from somewhere outside.
Are my thoughts correct and can any experienced C++ developer give an example where the above maybe used in real-world applications or it is very rare?