Note that there are some explanatory texts on larger screens.

plurals
  1. POError: declaration does not declare anything
    primarykey
    data
    text
    <p>This is a very amateur question with what I'm sure is going to be a very simple answer, but I cannot seem to figure out the problem. I have a header file with a corresponding .cpp file, but for some reason whenever I try to compile with g++, I keep getting the error:</p> <blockquote> <p>declaration does not declare anything</p> </blockquote> <p>I'm pretty sure the problem is that I'm not initializing the (only) variable in the file, but I'm not sure what to initialize it to. If anyone can help, I would greatly appreciate it! Here are my files:</p> <p>SymbolTableDictionary.h</p> <pre><code>#ifndef SymbolTable #define SymbolTable #include &lt;new&gt; #include &lt;iostream&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string&gt; using namespace std; #pragma once struct Symbol { std::string Name; int Address; Symbol::Symbol() { } Symbol::Symbol(const string name, int address) { std::string sym(name); this-&gt;Name = sym; this-&gt;Address = address; } }; extern map&lt;std::string, Symbol&gt; SymbolTable; #endif </code></pre> <p>SymbolTableDictionary.cpp</p> <pre><code>#include &lt;new&gt; #include &lt;iostream&gt; #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; #include &lt;string&gt; #include &lt;map&gt; #include "SymbolTableDictionary.h" using namespace std; map&lt;std::string, Symbol&gt; SymbolTable; </code></pre> <p>Compilation errors:</p> <pre><code>In file included from SymbolTableDictionary.cpp:8:0: SymbolTableDictionary.h:18:5: error: extra qualification ‘Symbol::’ on member ‘Symbol’ [-fpermissive] SymbolTableDictionary.h:21:5: error: extra qualification ‘Symbol::’ on member ‘Symbol’ [-fpermissive] SymbolTableDictionary.h:29:8: error: declaration does not declare anything [-fpermissive] SymbolTableDictionary.cpp:12:1: error: declaration does not declare anything [-fpermissive] </code></pre>
    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.
 

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