I know the concept of register variable and it\'s use cases but there are few questions in my mind based on what I have tried.
I cannot access the address
C and C++ are different languages.
In C, you cannot take the address of a variable with register storage. Cf. C11 6.7.1/6:
A declaration of an identifier for an object with storage-class specifier
registersuggests that access to the object be as fast as possible. The extent to which such suggestions are effective is implementation-defined.Footnote: The implementation may treat any
registerdeclaration simply as anautodeclaration. [...]
In C++, register is a deprecated, meaningless keyword that has no effect (except perhaps serve as a compiler hint), and variables declared as register still just have automatic storage. In particular, C++ doesn't have a "register" storage class. (It just has the storage class specifier, inherited from C.) Cf. C++11, 7.1.1/3:
A
registerspecifier is a hint to the implementation that the variable so declared will be heavily used. [ Note: The hint can be ignored and in most implementations it will be ignored if the address of the variable is taken. This use is deprecated [...]
Even in C nothing is actually guaranteed about how register storage is implemented (implementations are free to treat register as auto), but the language rules apply regardless.