Note that there are some explanatory texts on larger screens.

plurals
  1. POtemplate argument 1 is invalid (Code::Blocks Win Vista) - i don't use templates
    primarykey
    data
    text
    <p>I have some troubles with my school project.</p> <p>I have a class:</p> <pre><code>#include "Group.h" #include &lt;vector&gt; #include &lt;string&gt; using namespace std; class User{ private : string username; vector&lt;Group*&gt; groups; void show() { for(int i=0; i&lt;groups.size(); i++) cout &lt;&lt; groups[i]-&gt;getName() &lt;&lt; "\n"; } string getUsername(){return username;} }; </code></pre> <p>and </p> <pre><code>#include "User.h" #include &lt;vector&gt; #include &lt;string&gt; using namespace std; class Group{ private : string name; string getName(){return name;}; User *f; vector&lt;User*&gt; m; void show(){ for(int i=0; i&lt;m.size(); i++) cout &lt;&lt; m[i]-&gt;getUsername() &lt;&lt; "\n"; } }; </code></pre> <p>When I try compile it, it gives me errors:</p> <pre class="lang-none prettyprint-override"><code>E:\Group.h|31|error: ISO C++ forbids declaration of 'User' with no type| E:\Group.h|31|error: expected ';' before '*' token| E:\Group.h|33|error: 'User' was not declared in this scope| E:\Group.h|33|error: template argument 1 is invalid| E:\Group.h|33|error: template argument 2 is invalid| E:\Group.h|36|error: 'User' was not declared in this scope| E:\Group.h|36|error: template argument 1 is invalid| E:\Group.h|36|error: template argument 2 is invalid| E:\Group.h|47|error: 'User' has not been declared| E:\Group.h|47|error: 'User' was not declared in this scope| E:\Group.h|47|error: template argument 1 is invalid| E:\Group.h|47|error: template argument 2 is invalid| E:\Group.h|58|error: ISO C++ forbids declaration of 'User' with no type| E:\Group.h|58|error: expected ';' before '*' token| E:\Group.h|59|error: 'User' has not been declared| E:\Group.h|60|error: 'User' was not declared in this scope| E:\Group.h|60|error: template argument 1 is invalid| E:\Group.h|60|error: template argument 2 is invalid| E:\Group.h|61|error: 'User' was not declared in this scope| E:\Group.h|61|error: template argument 1 is invalid| E:\Group.h|61|error: template argument 2 is invalid| ||=== Build finished: 21 errors, 4 warnings ===| </code></pre> <p>what's wrong?</p> <p>It compiles only if I add <code>class User;</code> to Group.h file, and <code>class Group;</code> to User.h file but its not the point I’m looking for the right solution, not only the temporary one.</p> <p><strong>MY WHOLE PROJECT:</strong> <a href="http://www.speedyshare.com/jXYuM/proj.tar" rel="nofollow noreferrer">http://www.speedyshare.com/jXYuM/proj.tar</a></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