Note that there are some explanatory texts on larger screens.

plurals
  1. POC++ creating a linked list of linked lists
    primarykey
    data
    text
    <p>So, this is a part of my "linked_list.h" header:</p> <pre><code>template &lt;typename T&gt; class Linked_list { public: Linked_list(); ~Linked_list(); void add_first(const T&amp; x); //... }; </code></pre> <p>And a part of my implementation:</p> <pre><code>template &lt;typename T&gt; line 22: void Linked_list&lt;T&gt; :: add_first(const T&amp; x) { Node&lt;T&gt;* aux; aux = new Node&lt;T&gt;; aux-&gt;info = x; aux-&gt;prev = nil; aux-&gt;next = nil-&gt;next; nil-&gt;next-&gt;prev = aux; nil-&gt;next = aux; } </code></pre> <p>and I'm trying to make a linked list of linked lists of strings and add strings in one linked list of my linked list, like this:</p> <pre><code>Linked_list&lt;Linked_list&lt;string&gt; &gt; *l; l[0]-&gt;add_first("list"); //also I've tried l[0].add_first("list"); but it didn't work either </code></pre> <p>Thank you.</p> <p>Later edit: When I try l[0]->add_first("list") these are the errors:</p> <pre><code>main.cc: In function ‘int main()’: main.cc:22:22: error: no matching function for call to‘Linked_list&lt;Linked_list&lt;std::basic_string&lt;char&gt; &gt; &gt;::add_first(const char [4])’ main.cc:22:22: note: candidate is: In file included from main.cc:6:0: linked_list.cc:28:6: note: void Linked_list&lt;T&gt;::add_first(const T&amp;) [with T = Linked_list&lt;std::basic_string&lt;char&gt; &gt;] linked_list.cc:28:6: note: no known conversion for argument 1 from ‘const char [4]’ to ‘const Linked_list&lt;std::basic_string&lt;char&gt; &gt;&amp;’ </code></pre> <p>Later later edit: It worked finally, thank you for the ideas: I did just this and it's okay now:</p> <pre><code>Linked_list&lt;Linked_list&lt;string&gt; &gt; l; l[0].add_first("list"); </code></pre> <p>And it works :D. Thanks again !</p> <p>Neah..actually it doesn't work..</p>
    singulars
    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