<?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[ISO C++ forbids declaration of &#x27;list&#x27; with no type. ?????]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich hab mir zwei klassen gemacht welche eine Musiksammlung realisieren sollen.<br />
Beim compilieren bekomme ich in der zeile</p>
<pre><code class="language-cpp">list&lt;CLied&gt; m_musiksammlung;  // erzeugt eine leere Liste des Typs CLied
</code></pre>
<p>in der klasse CMusiksammlunn folgende Fehldermeldung: ISO C++ forbids declaration of 'list' with no type.</p>
<p>Weiß jemand was ich da falsch mache?</p>
<p>LG</p>
<pre><code class="language-cpp">using namespace std;

class CLied {
  bool found;
  string m_type;
  string m_titel;
  string m_interpret;
  string m_info;

  public:
    CLied () : m_type(&quot;&quot;), m_titel(&quot;&quot;), m_interpret(&quot;&quot;), m_info(&quot;&quot;) {
      }

    CLied (string type, string titel, string interpret, string info)
      : m_type(type), m_titel(titel), m_interpret(interpret), m_info(info) {
    }

    /* Kopier-Konstruktor */
    CLied (CLied&amp; lied)
      : m_type(lied.m_type), m_titel(lied.m_titel), m_interpret(lied.m_interpret), m_info(lied.m_info) {
    }

    string getLied () {
      return(m_type+&quot;, &quot;+m_titel+&quot;, &quot;+m_interpret+&quot;, &quot;+m_info);
    }

    bool getFound () {
      return (found);
    }

    void resetFound() {
      found = TRUE;
    }

    bool isFoundInType (string type) {
      if ( m_type.find(type,0) == string::npos ) {
        found = FALSE;
        return (found);
      }
      else {
        return (found);
      }
    }

    bool isFoundInTitel (string titel) {
      if ( m_titel.find(titel,0) == string::npos ) {
        found = FALSE;
        return (found);
      }
      else {
        return (found);
      }
    }

    bool isFoundInInterpret (string interpret) {
      if ( m_interpret.find(interpret,0) == string::npos ) {
        found = FALSE;
        return (found);
      }
      else {
        return (found);
      }
    }

};

class CMuskisammlung {
  list&lt;CLied&gt; m_musiksammlung;  // erzeugt eine leere Liste des Typs CLied
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/176806/iso-c-forbids-declaration-of-list-with-no-type</link><generator>RSS for Node</generator><lastBuildDate>Sat, 19 Sep 2026 15:29:34 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/176806.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 25 Mar 2007 10:24:55 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to ISO C++ forbids declaration of &#x27;list&#x27; with no type. ????? on Sun, 25 Mar 2007 10:24:55 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich hab mir zwei klassen gemacht welche eine Musiksammlung realisieren sollen.<br />
Beim compilieren bekomme ich in der zeile</p>
<pre><code class="language-cpp">list&lt;CLied&gt; m_musiksammlung;  // erzeugt eine leere Liste des Typs CLied
</code></pre>
<p>in der klasse CMusiksammlunn folgende Fehldermeldung: ISO C++ forbids declaration of 'list' with no type.</p>
<p>Weiß jemand was ich da falsch mache?</p>
<p>LG</p>
<pre><code class="language-cpp">using namespace std;

class CLied {
  bool found;
  string m_type;
  string m_titel;
  string m_interpret;
  string m_info;

  public:
    CLied () : m_type(&quot;&quot;), m_titel(&quot;&quot;), m_interpret(&quot;&quot;), m_info(&quot;&quot;) {
      }

    CLied (string type, string titel, string interpret, string info)
      : m_type(type), m_titel(titel), m_interpret(interpret), m_info(info) {
    }

    /* Kopier-Konstruktor */
    CLied (CLied&amp; lied)
      : m_type(lied.m_type), m_titel(lied.m_titel), m_interpret(lied.m_interpret), m_info(lied.m_info) {
    }

    string getLied () {
      return(m_type+&quot;, &quot;+m_titel+&quot;, &quot;+m_interpret+&quot;, &quot;+m_info);
    }

    bool getFound () {
      return (found);
    }

    void resetFound() {
      found = TRUE;
    }

    bool isFoundInType (string type) {
      if ( m_type.find(type,0) == string::npos ) {
        found = FALSE;
        return (found);
      }
      else {
        return (found);
      }
    }

    bool isFoundInTitel (string titel) {
      if ( m_titel.find(titel,0) == string::npos ) {
        found = FALSE;
        return (found);
      }
      else {
        return (found);
      }
    }

    bool isFoundInInterpret (string interpret) {
      if ( m_interpret.find(interpret,0) == string::npos ) {
        found = FALSE;
        return (found);
      }
      else {
        return (found);
      }
    }

};

class CMuskisammlung {
  list&lt;CLied&gt; m_musiksammlung;  // erzeugt eine leere Liste des Typs CLied
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1252091</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252091</guid><dc:creator><![CDATA[rabatz]]></dc:creator><pubDate>Sun, 25 Mar 2007 10:24:55 GMT</pubDate></item><item><title><![CDATA[Reply to ISO C++ forbids declaration of &#x27;list&#x27; with no type. ????? on Sun, 25 Mar 2007 10:31:27 GMT]]></title><description><![CDATA[<p>OK sorry ich könnt mich in den Hintern beißen.</p>
<p>Ich hab einfach nur die zeile</p>
<pre><code class="language-cpp">#include &lt;list&gt;
</code></pre>
<p>vergessen.</p>
<p>LG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252098</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252098</guid><dc:creator><![CDATA[rabatz]]></dc:creator><pubDate>Sun, 25 Mar 2007 10:31:27 GMT</pubDate></item><item><title><![CDATA[Reply to ISO C++ forbids declaration of &#x27;list&#x27; with no type. ????? on Sun, 25 Mar 2007 10:34:10 GMT]]></title><description><![CDATA[<p>BTW: Mach aus:</p>
<pre><code class="language-cpp">CLied (string type, string titel, string interpret, string info) 
      : m_type(type), m_titel(titel), m_interpret(interpret), m_info(info) { 
    } 

    /* Kopier-Konstruktor */ 
    CLied (CLied&amp; lied) 
      : m_type(lied.m_type), m_titel(lied.m_titel), m_interpret(lied.m_interpret), m_info(lied.m_info) { 
    }
</code></pre>
<p>besser:</p>
<pre><code class="language-cpp">CLied (const string&amp; typ, const string&amp; titel, const string&amp; interpret, const string&amp; info)
...

// Sowie
CLied (const CLied&amp; lied)
...
</code></pre>
<p>Und mische nicht dauernd englisch und deutsch sondern einige dich auf eine Sprache.</p>
<p>MfG SideWinder</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252102</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252102</guid><dc:creator><![CDATA[SideWinder]]></dc:creator><pubDate>Sun, 25 Mar 2007 10:34:10 GMT</pubDate></item><item><title><![CDATA[Reply to ISO C++ forbids declaration of &#x27;list&#x27; with no type. ????? on Sun, 25 Mar 2007 10:56:37 GMT]]></title><description><![CDATA[<p>Ok danke für die Anregungen.</p>
<p>Allerdings stehe ich leider vor meinem nächsten Problem:</p>
<pre><code class="language-cpp">class CMusiksammlung {
  list&lt;CLied&gt; m_musiksammlung;  // erzeugt eine leere Liste des Typs CLied
  list&lt;CLied&gt;::iterator m_itor_musiksammlung;

  public:
    CMusiksammlung () {
      m_itor_musiksammlung = m_musiksammlung.begin(); // Iterator an den Beginn der Liste
    }

    ~CMusiksammlung () {
      m_musiksammlung.clear(); // Inhalt der Liste löschen, Speicherplatz freigeben
      }

    void addLiedToMusiksammlung (string type, string titel, string interpret, string info) {
      CLied temp_lied (type, titel, interpret, info);
      cout &lt;&lt; temp_lied.getLied() &lt;&lt; endl &lt;&lt; endl;
      m_musiksammlung.push_back( temp_lied );
    }
};
</code></pre>
<p>Wenn ich die Funktion &quot;addLiedToMusiksammlung&quot; nun aus dem main mit</p>
<pre><code class="language-cpp">CMusiksammlung meine_musiksammlung;
  meine_musiksammlung.addLiedToMusiksammlung(&quot;Pop&quot;, &quot;Rocket Man&quot;, &quot;Elton John&quot;, &quot;asdf&quot;);
</code></pre>
<p>aufrufe, dann kommt eine ganz liste von compiler fehlern. bei der Zeile</p>
<pre><code class="language-cpp">m_musiksammlung.push_back( temp_lied );
</code></pre>
<p>Bin leider neu auf dem Gebiet der Objektorientieren Programmierung. Bin also für jede Hilfe dankbar.</p>
<p>LG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252114</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252114</guid><dc:creator><![CDATA[rabatz]]></dc:creator><pubDate>Sun, 25 Mar 2007 10:56:37 GMT</pubDate></item><item><title><![CDATA[Reply to ISO C++ forbids declaration of &#x27;list&#x27; with no type. ????? on Sun, 25 Mar 2007 11:38:21 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Es wäre natürlich sehr hilfreich die Fehlermeldungen zu posten <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /><br />
Als einzigstes Problem sehe ich den Kopierkonstruktor von CLied, den die Referenz muß als const übergeben werden, sonst kommt die list-interne Verwaltung nicht damit zurecht wenn Kopieen erzeugt werden müßen.</p>
<pre><code class="language-cpp">/* Kopier-Konstruktor */
    CLied (const CLied&amp; lied)
</code></pre>
<p>Siehe auch <a href="http://www.parashift.com/c++-faq-lite/const-correctness.html" rel="nofollow">Const Correctness</a></p>
<p>bis bald<br />
akari</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252143</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252143</guid><dc:creator><![CDATA[akari]]></dc:creator><pubDate>Sun, 25 Mar 2007 11:38:21 GMT</pubDate></item><item><title><![CDATA[Reply to ISO C++ forbids declaration of &#x27;list&#x27; with no type. ????? on Sun, 25 Mar 2007 11:43:09 GMT]]></title><description><![CDATA[<p>super danke. hat wunderbar funktioniert</p>
<p>hab mich leider bist jetzt immer gegen const gewehrt weil ich es für überflüssig gehalten habe. danke du hast mich vom gegenteil überzeugt.</p>
<p>LG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252147</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252147</guid><dc:creator><![CDATA[rabatz]]></dc:creator><pubDate>Sun, 25 Mar 2007 11:43:09 GMT</pubDate></item><item><title><![CDATA[Reply to ISO C++ forbids declaration of &#x27;list&#x27; with no type. ????? on Sun, 25 Mar 2007 11:51:51 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">#include &lt;iostream&gt;

class Song 
{
public:
	Song() :	m_type(&quot;&quot;), 
				m_title(&quot;&quot;), 
				m_interpret(&quot;&quot;), 
				m_info(&quot;&quot;) 
	{
	}

	Song(const std::string&amp; type, const std::string&amp; title, const std::string&amp; interpret, const std::string&amp; info)
		:	m_type(type), 
			m_title(title), 
			m_interpret(interpret), 
			m_info(info) 
	{
    }

	Song(const Song&amp; song)	:	m_type(song.m_type), 
								m_title(song.m_title), 
								m_interpret(song.m_interpret), 
								m_info(song.m_info) 
	{
    }

public:
	std::string get_formated() const
	{
		return std::string(m_type + &quot;, &quot; + m_title + &quot;, &quot; + m_interpret + &quot;, &quot; + m_info);
    }

	bool is_type_in(const std::string&amp; type) 
	{
		return (m_type.find(type) != std::string::npos);
    }

	bool is_titel_in(const std::string&amp; title) 
	{
		return (m_title.find(title) != std::string::npos);
    }

	bool is_interpret_in(const std::string&amp; interpret) 
	{
		return (m_interpret.find(interpret) != std::string::npos);
    }

private:
	std::string m_type;
	std::string m_title;
	std::string m_interpret;
	std::string m_info;
};

#include &lt;vector&gt;

class MusicCollection 
{
public:
	MusicCollection() 
	{
    }

    ~MusicCollection() 
	{
		m_items.clear(); // Muss nicht!
	}

	void add_song(const std::string&amp; type, const std::string&amp; title, const std::string&amp; interpret, const std::string&amp; info) 
	{
		m_items.push_back(Song(type, title, interpret, info));
    } 

	void add_song(const Song&amp; song)
	{
		m_items.push_back(song);
		std::cout &lt;&lt; song.get_formated() &lt;&lt; std::endl;
	}

	Song*	get_song(size_t id)
	{
		return (m_items.size() &gt; id ? &amp;m_items[id] : NULL); 
	}

private:
	std::vector&lt;Song&gt;		m_items;
}; 	

#include &lt;iostream&gt;

int main()
{
	MusicCollection test;
	test.add_song(&quot;Techno&quot;, &quot;Everytime We Touch&quot;, &quot;Cascada&quot;, &quot;Some information!&quot;);
	Song song(&quot;Rock&quot;, &quot;For You [Original Radio Edit]&quot;, &quot;Disco Boys&quot;, &quot;Covered version!&quot;);
	test.add_song(song);
	Song* pSong = test.get_song(0);
	if (pSong != NULL)
		std::cout &lt;&lt; pSong-&gt;get_formated() &lt;&lt; std::endl;
}
</code></pre>
<p>... mach das mal so ^^ ist ein wenig logischer ... vor allem das mit m_found als Membervariable von CLied war nicht so sinnvoll ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252154</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252154</guid><dc:creator><![CDATA[*D*Evil]]></dc:creator><pubDate>Sun, 25 Mar 2007 11:51:51 GMT</pubDate></item><item><title><![CDATA[Reply to ISO C++ forbids declaration of &#x27;list&#x27; with no type. ????? on Sun, 25 Mar 2007 12:41:41 GMT]]></title><description><![CDATA[<p>danke danke werd das mit der m_found nochmal überdenken. so ganz gefallen hat mir die lösung eh nicht aber das hatte für die aufgabe die es erfüllen sollte durchaus sinn gemacht. naja mal sehen vielleich fällt mir noch was anderes ein.</p>
<p>vielen dank jedenfalls,</p>
<p>LG</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1252191</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1252191</guid><dc:creator><![CDATA[rabatz]]></dc:creator><pubDate>Sun, 25 Mar 2007 12:41:41 GMT</pubDate></item></channel></rss>