I have a function named 'Address':
template <class Variable> unsigned long Address(Variable *X){
return (unsigned long &) X;
}
This function returns address of given argument. Even given argument is not a variable, it's returns a value and when i point this value to another pointer, i can access the value.
When i'm playing with this function, i see this function always return same value on non-variable (like "Hello world!") argument.
cout << "Address (?) of 'Hello world!' :" << Address("Hello world!") << "\n";
And
cout << "Address (?) of 'Hello world' :" << Address("Hello world") << "\n";
are gives same output. But when i try
cout << "Address (?) of 'Hello world!' :" << Address("Hello world!") << "\n";
cout << "Address (?) of 'Hello world!' :" << Address("Hello world") << "\n";
do this in same file, outputs are different.
What is why of this?