Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ error C2819: type 'List' does not have an overloaded member 'operator ->'
    text
    copied!<p>I keep getting this error - </p> <blockquote> <p>error C2819: type 'List' does not have an overloaded member 'operator ->'</p> </blockquote> <p>i can't figure out why? help?</p> <p><strong>Main.cpp</strong> - </p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;cassert&gt; using namespace std; #include "List.h" #include "Node.h" </code></pre> <p><strong>The error happens here:</strong></p> <pre><code>void PrintList ( List list ) { Node * temp = list.getFirst(); Node * temp2 = list-&gt;getLast(); while ( temp-&gt;getItemName() != temp2-&gt;getName() ) { cout &lt;&lt; temp.getItemName() &lt;&lt; endl; } } </code></pre> <p><strong>List.h</strong> -</p> <pre><code>#ifndef LIST_H #define LIST_H #include "Node.h" class List { private: Node * First; Node * Last; int num_in_list; public: List () { num_in_list = 0; First = NULL; Last = NULL; } int get_num_in_list() { return num_in_list; } Node * getFirst() { return First; } Node * getLast() { return Last; } void del_frnt (); void push_front (Node *); void push_back (Node *); void del_last (); void add (Node*); Node * pop_back (); Node * pop_front (); int search_item_list (string); Node * get (int); }; #endif </code></pre> <p><strong>List.cpp</strong> - </p> <pre><code>#include &lt;iostream&gt; #include &lt;string&gt; #include &lt;cassert&gt; #include "Node.h" #include "List.h" using namespace std; Node * List:: get ( int position_of_node ) { assert ( First != NULL); Node * temp = First; for (int i = 1; i &lt; position_of_node; i++) { temp = temp-&gt;getNext(); } return temp; } int List:: search_item_list (string item_searching_for ) { assert (First != NULL &amp;&amp; num_in_list != 0); int counter = 1; Node * temp = First; while ( temp-&gt;getItemName() != item_searching_for || temp-&gt;getNext() == NULL ) { temp = temp-&gt;getNext(); counter++; } return counter; } void List:: add (Node * node_to_be_added) { if (num_in_list == 0) { First = node_to_be_added; Last = node_to_be_added; } else if (num_in_list != 0 ) { Last-&gt;setNext(node_to_be_added); node_to_be_added-&gt;setPrevous(Last); Last = node_to_be_added; } num_in_list++; } Node * List :: pop_back ( ) { assert (Last != NULL); if ( num_in_list &gt; 1) { Node * temp = Last; Last = Last-&gt;getPrevous(); Last-&gt;setNext(NULL); temp-&gt;setNext(NULL); temp-&gt;setPrevous(NULL); return temp; } else if ( num_in_list == 1 ) { Node * temp = First; First = NULL; return temp; } else return NULL; } Node * List:: pop_front ( ) { assert ( First != NULL &amp;&amp; num_in_list &gt; 0); if ( num_in_list &gt; 1 ) { Node * temp = First; First = First-&gt;getNext(); First-&gt;setPrevous(NULL); temp-&gt;setNext(NULL); temp-&gt;setPrevous(NULL); return temp; } else if ( num_in_list == 1) { Node * temp = First; First = NULL; return temp; } else return NULL; } void List:: del_last ( ) { assert ( Last != NULL ); if ( num_in_list &gt; 1) { Node * temp_node = Last-&gt;getPrevous(); Node * new_last = Last; temp_node-&gt;setNext(NULL); delete new_last; num_in_list--; } else if ( num_in_list == 1) { Node * temp = First; delete temp; num_in_list = 0; First = NULL; } } void List:: del_frnt ( ) { assert ( First != NULL); if ( num_in_list &gt; 1) { Node * saveFirst = First; First-&gt;getNext()-&gt;setPrevous(NULL); First = First-&gt;getNext( ); delete saveFirst; num_in_list--; } else if ( num_in_list == 1 ) { Node * saveFirst = First; delete saveFirst; num_in_list = 0; First = NULL; } } void List:: push_back (Node * new_node) { assert ( Last != NULL ); Last-&gt;setNext(new_node); new_node-&gt;setPrevous(Last); Last = new_node; num_in_list++; } void List:: push_front (Node * new_node) { if ( First != NULL) { First-&gt;setPrevous(new_node); new_node-&gt;setPrevous(NULL); new_node-&gt;setNext(First); First = new_node; num_in_list++; } else if ( First == NULL ) { First = new_node; Last = new_node; num_in_list = 1; } } </code></pre> <p><strong>Node.h</strong> - </p> <pre><code>#ifndef NODE_H #define NODE_H #include &lt;string&gt; using namespace std; class Node { private: string ItemName; string Quantity; Node * Next; Node * Prevous; public: Node () { ItemName = " "; Quantity = " "; } void setItemName (string a) { ItemName = a; } string getItemName () { return ItemName; } void setQuantity (string a) { Quantity = a; } string getQuantity () { return Quantity; } void setNext (Node * a) { *Next = *a; } Node * getNext () { return Next; } void setPrevous (Node * a) { *Prevous = *a; } Node * getPrevous () { return Prevous; } }; #endif </code></pre> <p>Note:I know what I'm doing is just a list, but for a collage class I have to do it :) -Any help / pointers / how to do things better would be <strong>GREAT!!!</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload