So, I am new to pointers/addresses and I have a generic function that prints the address of a variable passed to it as a parameter. However, in the following snippet why the addresses are different despite they belong to the same variable?
template <typename T>
void printAddressOf(T t)
{
std::cout << &t << std::endl;
}
int main(int argc, char **argv)
{
int x = 12;
printAddressOf(x);
std::cout << &x;
return 0;
}
The values that I get as an output are...
0x7ffee2c6f86c
0x7ffee2c6f89c
Can someone explain this behaviour why this happens?