0

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?

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by tkud
0

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)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.