c++ push_back doesn't work as it is supposed

I have a class symbol_table that has a vector of objects of another class row_st.also I have an enter method where inserts objects of row_st with a passed name into the vector of desired symbol_table.but when I call the enter to enter objects with name :
a;b;c;Iwill get the following result: a,b,c;b,c;c.the first element of vector gets the name of all the entered objects. and the second element also gets the name of the later enters.

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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
class row_st

      {

       public:

          char* name;

          type_u type;//int:0,flaot:1;char:2,bool:3,array:

          int offset;

          symbol_table *next;

          symbol_table *current;

      };
class symbol_table

      {

       public:

         vector <row_st *> row;

         int type;

         int header;

         int starting_stmt;

         int index;

         int i;

         symbol_table *previous;

         symbol_table(){ header=0;

          previous=0; index=0;i=0;starting_stmt=0;}


      };
//and here it is the enter method:

int enter(symbol_table *table,char* name,type_u type){
	 
         row_st *t=new row_st;

	t->name=name;

	t->type=type;

	t->offset=table->index;

	t->current=table;

	table->index++;

	t->next=0;

	table->row.push_back(t);


	table->header +=1;

	return table->row.size()-1;
       }




the push_backed elements all points to the same address.the new call makes the same row_st every time it is called.what should I do?
Topic archived. No new replies allowed.