adding node to linked list, seems like when my node picks up new variable, first node changes to that

I am adding reference of node to linked list, but when node picks up the new variables, my first node changes to the new node. I understand I am using reference (address) to store and changing node to pick up new variable is same as changing first node to the new one. but I can't figure out how to solve this. how can I make my nodes in list to not change?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
struct Node {
		Transaction T;
		Node* Next;
		Node* Prev;
		Node (const double s, const double p, const string a, const string ss
			, const string t, const int i){
			T.share = s;
			T.price = p;
			T.action = a;
			T.security = ss;
			T.transactionDate = t;
			T.intTransactionDate = i;
			Next = NULL;
			Prev = NULL;
		}
};


while(!token.isEndOfInput()){
		if (token.isTransaction()){
			tran.action = token.getAction();
			tran.price = token.getPrice();
			tran.security = token.getSecurity();
			tran.share = token.getQuantity();
			tran.intTransactionDate = token.getYear()*10000
									+ token.getMonth()*100
									+ token.getDay();
			tran.transactionDate = to_string(tran.intTransactionDate);

			Node n(tran.share, tran.price, tran.action, tran.security
					, tran.transactionDate, tran.intTransactionDate);

			tranLL->insert(&n);
Last edited on
Registered users can post here. Sign in or register to post.