object as parameter

Hello!
I want to make a list of classes! How can I do it?
I tried in this way:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
class Pont {
  //..
}*firs, *last;
void putin (Pont tmp) {
  last->next = new Pont;
  last->next = &tmp;
  last = last->next;
};
int main () {
  //initialization of *first
  last=first
  for (int i=0;i<100;i++) {
    Pont temp(i,..);
    putin(temp);
  };
}

It doesn't work, because the temp after the first initialization ocupies the same place in the memory; so &temp remains the same;
I suppose that I have to use some pointers but I don't know how...
Please give me some advice.
Thanks in advance!
1
2
3
4
5
void putin (Pont tmp) {
  last->next = new Pont;
  *last->next = tmp; // get the value of temp, not its address
  last = last->next;
};

Topic archived. No new replies allowed.