Note that there are some explanatory texts on larger screens.

plurals
  1. POLinkedList Part
    text
    copied!<p>I think I might have done something right, headByRating and headByName both refer to the same address.</p> <p>I have been drawing diagras working all day trying new things etc, and i havent really made any progress.</p> <p>I have two list pointers, headByRating and headByName. and two node pointers nextByName and nextByRating.</p> <p>Somehow I need to be able to sort this stuff by its name and rating. I've been thinking that I do that by each of the ptrs' address'.</p> <p>2 statements as an example that I have been trying to sort:</p> <pre> //main.cpp list *wineries = new list(); wineries->insert(winery("Lopez Island Vinyard", "San Juan Islands", 7, 95)); wineries->insert(winery("Gallo", "Napa Valley", 200, 25)); </pre> <p>the winery ctor is fine everything is allocated and into the object at this point:</p> <pre> //list.cpp void list::insert( const winery& winery ) { list *listPtr = new list(); // havent really used the list obj. yet. node *current = new node( winery ); // winery is now a node. node *temp = current; // temp knows about the nodes address. while ( temp->nextByName != NULL ) { // check for null and reassign temp = temp->nextByName; } node *new_node = new node( winery ); // creating a new node. new_node->item = winery; new_node->nextByName = new_node; new_node->nextByRating = new_node; } </pre> <pre> // list.h struct node { winery item; node * nextByName; node * nextByRating; }; class list { ... private: node * headByName; node * headByRating; }; </pre> <p>What is a good approach to this? I dont think im doing this right. </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