Linked list error

I am using a linked list for the first time and am trying to add an entry to the list. However I am getting an error in this section of code:

1
2
3
4
5
if (is_tri == true) {
                            //add the triangle to the list
                            ListElement *p = new triangle((*nodeVec[i]), (*nodeVec[j]), (*nodeVec[k]));
                            triList.AddElement(p);
                        }


The error is - error: cannot convert 'triangle*' to 'ListElement*' in initialization

where 'triangle' is a class I have created that deals with the three nodes of a triangle (each node has x, y, z components) and 'nodeVec' is a vector of nodes.

Any suggestions?
I'm thinking along the lines of ..

1
2
3
4
5
6
7
8
9
10
11
struct ListElement {
        triangle *data;
        ListElement *next, *prev;
};




ListElement *p = new ListElement;
p->data = new triangle((*nodeVec[i]), (*nodeVec[j]), (*nodeVec[k]));
triList.AddElement(p);


But I'm likely wrong. heh.
Last edited on
I found that I actually did not use inheritance correctly so have it sorted.

Thanks

Topic archived. No new replies allowed.