In C, we cannot use & to find out the address of a register variable but in C++ we can do the same. Why is it legal in C++ but not in C? Can someone please explain this
Sorry about the super late answer.
The problem is that, in C, register originally meant storing values in a register which is why only int and char can be used for it. But with time and especially standard C++, it broadened to "fast access" rather than "in register of CPU".
So in C++, an array maybe a register type but we know that it is not possible to store arrays in a CPU register. Hence, it is logically okay to address a C++ register (in the above sense), but will still make no sense if the values are actually in a CPU register.