title: "Declaration of xxx outside of class is not definition" error
body: <p>This is the error:</p>
  <blockquote>
  <p>error: declaration of 'DataStream::DataStream()' outside of class is not definition [ fpermissive]| <br />
  ||=== Build finished: 1 errors, 0 warnings (0 minutes, 0 seconds) ===|</p>
  </blockquote>
  <p>This is the main.cpp file:</p>
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &quot;DataStream.h&quot;
  #include &quot;MsgPacket.h&quot;
  
  using namespace std;
  
  DataStream * Packet = new DataStream();
  DataStream::DataStream();
  
  int main()
  {
      int source;
      int destination;
      int type;
      int port;
      int input;
      std::string data;
  
      cout &lt;&lt; &quot;My Assignment&quot; &lt;&lt; endl;;
  
      MsgPacket * Packet = new MsgPacket(source, destination, type, port, data);
  }
  </code></pre>
  <p>This is the MsgPacket.h</p>
  <pre><code>#ifndef MSGPACKET_H
  #define MSGPACKET_H
  
  #include &lt;string&gt;
  #include &quot;PacketAddress.h&quot;
  
  using namespace std;
  
  class MsgPacket : public PacketAddress
  {
  
  public:
      MsgPacket();
      MsgPacket (const MsgPacket &amp; rhs);
      MsgPacket(string dataIn);
      MsgPacket(int source, int destination, int port, int type, std::string data);
      MsgPacket(int, char data);
      string toString();
      string getData() const {return _data;};
      void setData(string inData) {_data = inData;};
      string dataOutput();
      virtual ~MsgPacket();
      virtual MsgPacket * Clone() { return new MsgPacket(*this); }
  protected:
      string _data;
  };
  
  #endif // MSGPACKET_H
  </code></pre>
  <p>And finally this is the MsgPacket.cpp</p>
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;string&gt;
  #include &lt;iomanip&gt;
  #include &quot;msgpacket.h&quot;
  
  using namespace std;
  
  MsgPacket::MsgPacket():
  PacketAddress(0, 0)
  {
  
  }
  
  MsgPacket::MsgPacket (const MsgPacket &amp; rhs):
  PacketAddress(rhs),
  _data(rhs.getData())
  {
  
  }
  
  MsgPacket::MsgPacket(string dataIn):
  PacketAddress(0,0)
  {
      string temp;
  
      temp = dataIn.substr (0, 4);
      _source = atoi(temp.c_str());
  
      temp = dataIn.substr (5, 4);
      _dest = atoi(temp.c_str());
  
      temp = dataIn.substr (10, 4);
      _type = atoi(temp.c_str());
  
      temp = dataIn.substr (15, 4);
      _port = atoi(temp.c_str());
      _data = dataIn.substr (20, dataIn.length());
  
      #ifdef DEBUG
      cout &lt;&lt; &quot;CREATE PACKET: &quot; &lt;&lt; this-&gt;toString() &lt;&lt; endl;
      #endif
  }
  
  MsgPacket::MsgPacket(int source, int destination):
  PacketAddress(source, destination)
  {
  
  }
  
  MsgPacket::MsgPacket(int source, int destination, int port):
  PacketAddress(source, destination)
  {
      _port = port;
  }
  
  MsgPacket::MsgPacket(int source, int destination, int type, int port, std::string       data):
  PacketAddress(source, destination)
  {
      _source = source;
      _dest = destination;
      _type = type;
      _data = data;
      _port = port;
  }
  
  string MsgPacket::dataOutput()
  {
      stringstream output; // Create a stringstream
      output &lt;&lt; setw(4) &lt;&lt; setfill('0') &lt;&lt; _source &lt;&lt; &quot;:&quot;
             &lt;&lt; setw(4) &lt;&lt; setfill('0') &lt;&lt;  _dest  &lt;&lt; &quot;:&quot;
             &lt;&lt; setw(4) &lt;&lt; setfill('0') &lt;&lt; _type   &lt;&lt; &quot;:&quot;
             &lt;&lt; setw(4) &lt;&lt; setfill('0') &lt;&lt; _port   &lt;&lt; &quot;:&quot;
             &lt;&lt; _data;
      return output.str();
  }
  
  string MsgPacket::toString()
  {
      stringstream output; // Create a stringstream
      output &lt;&lt; &quot;[&quot; &lt;&lt; showbase &lt;&lt; hex
             &lt;&lt; this &lt;&lt; &quot;] S:[&quot;
             &lt;&lt; _source &lt;&lt; &quot;] D:[&quot;
             &lt;&lt; _dest &lt;&lt; &quot;] P:[&quot;
             &lt;&lt; _type &lt;&lt; &quot;] T:[&quot;
             &lt;&lt; _port &lt;&lt; &quot;]&quot;
             &lt;&lt; &quot; DATA[&quot; &lt;&lt; _data &lt;&lt; &quot;]&quot;;
      return output.str();
  }
  </code></pre>