Note that there are some explanatory texts on larger screens.

plurals
  1. POLinked list returning variables from a function
    primarykey
    data
    text
    <p>Hi i am doing a project for college and i am stuck at a part. I am using linked list in c++. I have to set up a class called Book which has variables 'title', 'author', 'ISBN' and 'availability'. I set it up like this in my main using a prototype for the function and the function being called elsewhere.</p> <pre><code>//the prototype list&lt;Book&gt; bookSetUp(); int main() { //the variable in main that will have the list list&lt;Book&gt; bookList; //the list being populated in function elsewhere so as to not mess up the main bookList = bookSetUp(); // more stuff in main } //sets up the book vector list by populating it //title, author, ISBN, availability list&lt;Book&gt; bookSetUp() { //creates a temp vector to pass it back to the actual vector to be used in the main list&lt;Book&gt; temp; //The items that populate the list Book a("A Tale of Two Cities", "Charles Dickens", 1203456, true); Book b("Lord of the rings", "J.R.R Tolkein", 123456, true); Book c("Le Petit Prince", "Antoine de Saint-Exupéry", 123457, true); Book d("And Then There Were None", "Agatha Christie", 123458, true); Book e("Dream of the Red Chamber","Cao Xueqin",123459, true); Book f("The Hobbit","J.R.R Tolkein",123467, true); //pushes the items into the vector temp.push_back(a); temp.push_back(b); temp.push_back(c); temp.push_back(d); temp.push_back(e); temp.push_back(f); //returns the list list&lt;Book&gt;::iterator pos; pos = temp.begin(); while(pos != temp.end()) { return pos; if(pos != temp.end()) { pos++; } } } </code></pre> <p>I know that my links between files are grand i just cant get the 'temp' list to return the values. Any help would be greatly appreciated. Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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