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:

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 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:

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?

You might need to post your full code. For one, is triangle inheriting from ListElement? If it's not then the compiler's right.. you can't convert (unless u want to reinterpret_cast, which is not advisable)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.