persistent objects problem?

hi, i'm having trouble making something resembling a circular linked list.

here is my code: (i haven't gotten very far)

RingNode class:
1
2
3
4
5
6
class RingNode {
public:
    RingNode(const int& i=0 ): data(i), next(NULL){}
private:
    int data;
    RingNode* next;


function implementation in Ring.cpp:
1
2
3
4
5
6
7
8
9
RingNode* Ring::Insert(const int& d)
{
	RingNode* rn = new RingNode;
	rn->data = d;

	cout << d << ": " << &rn << endl;
	
	//return something later
}


in main.cpp
1
2
3
4
Ring testring;
testring.Insert(1);
testring.Insert(2);
testring.Insert(3);


output:
1
2
3
1: 0x28fec8
2: 0x28fec8
3: 0x28fec8


please help! i don't know why they are all pointing to the same address! i thought dynamic variables were supposed to be persistent (is that the word)? looking forward to your responses, and thanks in advance. :(
&rn gives you the address of the pointer itself. rn gives you the address the pointer points to.
<3 <3 <3 <3 <3 <3 <3
resolved.
Topic archived. No new replies allowed.