Strange Problem

I have a template class

1
2
3
4
5
6
7
8
9
10
11
12
13
14
template<class T> class Atomic
{
    volatile T value;

     T* getReference()
     {
         return &value;
     }

     Atomic()
     {
        cout<<&value<<endl;
     }
}


Value returned by geReference function and printed inside the constructor doesn't match. Why so? Can someone please explain this?
What is T? ie, what is Atomic being instantiated with?

if char, then line 12 likely crashes. (To print out the address of a variable using cout generically you need some nasty typecasting since char* are interpreted by the IO stream library as C-style strings).
T is just a variable. This is a template class. I have used T for many primitive and user-defined data types. like int, float, bool, Node and etc. And I don't need to explicitely do any typecasting. So, I don't understand why the addresses are different?
Can you provide example code that demonstrates the problem?
Topic archived. No new replies allowed.