<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Type unexpected.]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe ein Problem, dem ich einfach nicht auf den Grund komme. Ich habe eine simple header datei, die in meinen augen ok ist, sie will aber nicht compilieren.<br />
Ich arbeite mit MS Visual Studio .NET 2003, und folgendes ist mein Problem fall:</p>
<pre><code class="language-cpp">#ifndef __ENTITY_H__
#define __ENTITY_H__

typedef unsigned int IdType;

class Entity {
protected:
  /** The entity's Id **/
  IdType _id;

  /** A C Style String representing the name of the entity **/
  char *_name;

private:
  /**
   * Creates an entity and sets its id and name to the given values.
   **/
  Entity(const IdType id, const char *name const) {
    _id = id;
    _name = new char[strlen(name) + 1];
    strcpy(_name, name);
  }

  virtual ~Entity(void) {
    delete _name;
  }
};
#endif
</code></pre>
<p>Ich bekomme folgende compiler Meldung:<br />
entity.h(18) : error C2226: syntax error : unexpected type 'IdType'</p>
<p>Zeile 18 ist der constructor.</p>
<p>Ich hab schon im netz gesucht und gegoogled aber keine Lösung gefunden. Ich hoffe das es ein simpler Anfänger Fehler ist und ihr mir hier schnell weiterhelfen könnt.</p>
<p>Danke schnonmal,<br />
rand</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/145047/type-unexpected</link><generator>RSS for Node</generator><lastBuildDate>Wed, 02 Sep 2026 20:39:31 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/145047.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 24 Apr 2006 12:17:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Type unexpected. on Mon, 24 Apr 2006 12:17:48 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich habe ein Problem, dem ich einfach nicht auf den Grund komme. Ich habe eine simple header datei, die in meinen augen ok ist, sie will aber nicht compilieren.<br />
Ich arbeite mit MS Visual Studio .NET 2003, und folgendes ist mein Problem fall:</p>
<pre><code class="language-cpp">#ifndef __ENTITY_H__
#define __ENTITY_H__

typedef unsigned int IdType;

class Entity {
protected:
  /** The entity's Id **/
  IdType _id;

  /** A C Style String representing the name of the entity **/
  char *_name;

private:
  /**
   * Creates an entity and sets its id and name to the given values.
   **/
  Entity(const IdType id, const char *name const) {
    _id = id;
    _name = new char[strlen(name) + 1];
    strcpy(_name, name);
  }

  virtual ~Entity(void) {
    delete _name;
  }
};
#endif
</code></pre>
<p>Ich bekomme folgende compiler Meldung:<br />
entity.h(18) : error C2226: syntax error : unexpected type 'IdType'</p>
<p>Zeile 18 ist der constructor.</p>
<p>Ich hab schon im netz gesucht und gegoogled aber keine Lösung gefunden. Ich hoffe das es ein simpler Anfänger Fehler ist und ihr mir hier schnell weiterhelfen könnt.</p>
<p>Danke schnonmal,<br />
rand</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1043940</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043940</guid><dc:creator><![CDATA[rand]]></dc:creator><pubDate>Mon, 24 Apr 2006 12:17:48 GMT</pubDate></item><item><title><![CDATA[Reply to Type unexpected. on Mon, 24 Apr 2006 12:26:07 GMT]]></title><description><![CDATA[<p>Das sieht so aus, als ob da ein paar const's zu viel sind (&quot;IdType id&quot; muß nicht konstant sein, und &quot;char* name <em>const</em>&quot; habe ich noch nie gesehen).</p>
<p>PS: Im Destruktor solltest du übrigens delete[] verwenden - und einen Copy-Ctor und operator= benötigst du auch noch.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1043954</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043954</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 24 Apr 2006 12:26:07 GMT</pubDate></item><item><title><![CDATA[Reply to Type unexpected. on Mon, 24 Apr 2006 12:38:46 GMT]]></title><description><![CDATA[<p>Ok, habs hinbekommen.</p>
<p>zum einen hatte der &lt;string.h&gt; include für strlen gefehlt.<br />
Zum anderen hattest Du Recht mit dem const char *name <em>const</em>.<br />
Wenn ich das wegnehme klappts, finde ich allerdings ulkig, weil ich nicht weis<br />
wieso das nicht gehen sollte.</p>
<p>Die Bedeutung von const char* ist klar ein konstanter char Pointer, und eigentlich ist const char * const ein konstanter charpointer mit konstantem inhalt.</p>
<p>Hab ich hier her: <a href="http://www.mathematik.uni-marburg.de/~cpp/pointer/const.html" rel="nofollow">http://www.mathematik.uni-marburg.de/~cpp/pointer/const.html</a><br />
Daher bin ich überhaupt auf die Idee gekommen sowas zu machen.</p>
<p>Danke, Du hast mein Tag gerettet <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /><br />
rand</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1043964</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043964</guid><dc:creator><![CDATA[rand]]></dc:creator><pubDate>Mon, 24 Apr 2006 12:38:46 GMT</pubDate></item><item><title><![CDATA[Reply to Type unexpected. on Mon, 24 Apr 2006 12:40:49 GMT]]></title><description><![CDATA[<p>rand schrieb:</p>
<blockquote>
<p>Die Bedeutung von const char* ist klar ein konstanter char Pointer, und eigentlich ist const char * const ein konstanter charpointer mit konstantem inhalt.</p>
</blockquote>
<p>Ja, aber wenn du dem einen Namen geben willst, heißt das &quot;const char* const name&quot; (achte auf die Reihenfolge!)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1043968</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043968</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 24 Apr 2006 12:40:49 GMT</pubDate></item><item><title><![CDATA[Reply to Type unexpected. on Mon, 24 Apr 2006 12:48:00 GMT]]></title><description><![CDATA[<p>Ah! Oh!</p>
<p>2:0 für Dich! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Gruß,<br />
rand</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1043979</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1043979</guid><dc:creator><![CDATA[rand]]></dc:creator><pubDate>Mon, 24 Apr 2006 12:48:00 GMT</pubDate></item></channel></rss>