Linked List - Copy Constructor | Node problem

Hello, I have a slight problem.

I have a constructed a copy constructor but what I need to do is to is to add the information that every node has in the list to the add function.
Here is my ShapeList.cpp file (do note it's just part of it):

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
class ShapeNode {
public:
  const Shape* s;
  ShapeNode* bak;
  ShapeNode* fram;
  ShapeNode(){
      fram = NULL;
      s = NULL;
  }
  ShapeNode(const Shape* _s, ShapeNode* _bak, ShapeNode* _fram) : s(_s), bak(_bak), fram(_fram) {}
  ~ShapeNode() {}

int ShapeList::Rkn = 0;
int ShapeList::AntLst = 0;

ShapeList::ShapeList() {
  AntLst++;
  ny = new ShapeNode(0, 0, 0);
  ny->fram = ny->bak = ny;
}

ShapeList::ShapeList(const ShapeList &listofShapes) : ny(NULL) {
  NwLst = new ShapeList();
  ShapeNode* cur = listofShapes.ny;
  ShapeNode* sisList = NULL;
  int vrl = 0;

  while(vrl < Rkn){
    ++vrl;
    ShapeNode* n = new ShapeNode;
    n->s = cur->s;
    NwLst->add(n->s);

    if(!ny){
        ny = n;
        sisList = ny;
    }else {
        sisList->fram = n;
        sisList = n;
    }
    cur = cur->fram;
if (vrl>10) break;
  }
}

void ShapeList::add(const Shape& s){
  Rkn++;objekt i listan
  const Shape* tmpPek = &s;
  tmpPek = tmpPek->clone();
  ShapeNode *tmp = ny;
  ny = new ShapeNode(tmpPek, 0, tmp);
  tmp->bak = ny;
}


So my question is this, is it possible to call the function add (to add the nodes shape-object it has) with the copy constructor or do I have to redo it?

Thanks in advance !
Topic archived. No new replies allowed.