<?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[aha, non-class type, obwohl als Klasse definiert?]]></title><description><![CDATA[<p>Hi,<br />
ganz schnell: folgenden Code habe nach einem älteren Buch geschrieben:</p>
<p>-----------<br />
class ListenElement<br />
{<br />
friend class Liste;</p>
<p>protected:<br />
ListenElement(ListenElement *p=0, ListenElement *n=0) : previous(p), next(n){}<br />
ListenElement *previous;<br />
ListenElement *next;</p>
<p>public:<br />
void Print(void) {cout &lt;&lt; this &lt;&lt; endl;}<br />
ListenElement(void) : previous(0),next(0){}<br />
};</p>
<p>class IntElement : public ListenElement<br />
{<br />
private:<br />
int data;<br />
public:<br />
IntElement(int, ListenElement*, ListenElement*);<br />
void Print(void) {cout &lt;&lt; data &lt;&lt; endl;}<br />
};</p>
<p>IntElement::IntElement(int d, ListenElement *p=0, ListenElement *n=0) : data(d), ListenElement(p,n) {}</p>
<p>ListenElement le();<br />
IntElement ie(20,0,0);<br />
int main(void)<br />
{</p>
<p>le.Print();<br />
ie.Print();<br />
}</p>
<p>-----------------------</p>
<p>bekomme aber beim Kompilieren folgende Fehlermeldung:<br />
request for member âPrintâ in âleâ, which is of non-class type âListenElement ()()â<br />
.. was sich auf den Funktionsaufruf le.Print() bezieht.<br />
Wurde mit g++ 4.1.3 kompiliert.</p>
<p>A propos: wie bringe ich die Shell/das Terminal dazu, mir schöne &quot;&quot; statt â anzuzeigen?</p>
<p>Danke für jede Hilfe,<br />
Jens</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/222504/aha-non-class-type-obwohl-als-klasse-definiert</link><generator>RSS for Node</generator><lastBuildDate>Mon, 05 Oct 2026 02:54:15 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/222504.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 13 Sep 2008 16:06:51 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to aha, non-class type, obwohl als Klasse definiert? on Sat, 13 Sep 2008 16:06:51 GMT]]></title><description><![CDATA[<p>Hi,<br />
ganz schnell: folgenden Code habe nach einem älteren Buch geschrieben:</p>
<p>-----------<br />
class ListenElement<br />
{<br />
friend class Liste;</p>
<p>protected:<br />
ListenElement(ListenElement *p=0, ListenElement *n=0) : previous(p), next(n){}<br />
ListenElement *previous;<br />
ListenElement *next;</p>
<p>public:<br />
void Print(void) {cout &lt;&lt; this &lt;&lt; endl;}<br />
ListenElement(void) : previous(0),next(0){}<br />
};</p>
<p>class IntElement : public ListenElement<br />
{<br />
private:<br />
int data;<br />
public:<br />
IntElement(int, ListenElement*, ListenElement*);<br />
void Print(void) {cout &lt;&lt; data &lt;&lt; endl;}<br />
};</p>
<p>IntElement::IntElement(int d, ListenElement *p=0, ListenElement *n=0) : data(d), ListenElement(p,n) {}</p>
<p>ListenElement le();<br />
IntElement ie(20,0,0);<br />
int main(void)<br />
{</p>
<p>le.Print();<br />
ie.Print();<br />
}</p>
<p>-----------------------</p>
<p>bekomme aber beim Kompilieren folgende Fehlermeldung:<br />
request for member âPrintâ in âleâ, which is of non-class type âListenElement ()()â<br />
.. was sich auf den Funktionsaufruf le.Print() bezieht.<br />
Wurde mit g++ 4.1.3 kompiliert.</p>
<p>A propos: wie bringe ich die Shell/das Terminal dazu, mir schöne &quot;&quot; statt â anzuzeigen?</p>
<p>Danke für jede Hilfe,<br />
Jens</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1581391</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1581391</guid><dc:creator><![CDATA[Ichbins-Jens]]></dc:creator><pubDate>Sat, 13 Sep 2008 16:06:51 GMT</pubDate></item><item><title><![CDATA[Reply to aha, non-class type, obwohl als Klasse definiert? on Sat, 13 Sep 2008 16:21:12 GMT]]></title><description><![CDATA[<p>Dieser Thread wurde von Moderator/in <a href="http://www.c-plusplus.net/forum/profile-var-mode-is-viewprofile-and-u-is-1819.html" rel="nofollow">rüdiger</a> aus dem Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-10.html" rel="nofollow">ANSI C</a> in das Forum <a href="http://www.c-plusplus.net/forum/viewforum-var-f-is-15.html" rel="nofollow">C++</a> verschoben.</p>
<p>Im Zweifelsfall bitte auch folgende Hinweise beachten:<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-39405.html" rel="nofollow">C/C++ Forum :: FAQ - Sonstiges :: Wohin mit meiner Frage?</a></p>
<p><em>Dieses Posting wurde automatisch erzeugt.</em></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1581404</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1581404</guid><dc:creator><![CDATA[C++ Forumbot]]></dc:creator><pubDate>Sat, 13 Sep 2008 16:21:12 GMT</pubDate></item><item><title><![CDATA[Reply to aha, non-class type, obwohl als Klasse definiert? on Sat, 13 Sep 2008 16:27:59 GMT]]></title><description><![CDATA[<p>Ah, der Klassiker:</p>
<p>Ichbins-Jens schrieb:</p>
<blockquote>
<pre><code class="language-cpp">...
        ListenElement le();
...
</code></pre>
</blockquote>
<p>Vergleiche das mal mit</p>
<pre><code class="language-cpp">int f();
</code></pre>
<p>Na ? Was deklarierst Du damit ? <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>genausowenig, wie Du</p>
<pre><code class="language-cpp">int i();
</code></pre>
<p>schreibst, wenn Du eine integer-Variable deklarierst, brauchst Du oben die &quot;()&quot;...</p>
<p>Gruß,</p>
<p>Simon2.</p>
<p>BTW: Bitte cpp-tags verwenden ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1581412</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1581412</guid><dc:creator><![CDATA[Simon2]]></dc:creator><pubDate>Sat, 13 Sep 2008 16:27:59 GMT</pubDate></item><item><title><![CDATA[Reply to aha, non-class type, obwohl als Klasse definiert? on Sat, 13 Sep 2008 16:26:50 GMT]]></title><description><![CDATA[<p><code>ListenElement le();</code><br />
Der Compiler sieht <code>le</code> hier nicht als Objekt, sondern als Funktionsdeklaration. Richtig wäre es ohne die Klammern:<br />
<code>ListenElement le;</code></p>
<p>Und zum zweiten Problem:<br />
Da müsste man wissen, welches Betriebsystem du benutzt und du wärst damit sowieso im falschen Forum. Also ka ...</p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1581414</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1581414</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Sat, 13 Sep 2008 16:26:50 GMT</pubDate></item><item><title><![CDATA[Reply to aha, non-class type, obwohl als Klasse definiert? on Sat, 13 Sep 2008 16:33:16 GMT]]></title><description><![CDATA[<p>Aha, verstehe^^. Danke. Ja, ich habe die Klammern eingefügt, obwohl es ohne im Buch stand. Aber ohne bekomme ich folgende Fehlermeldung:<br />
list.cpp:30: error: call of overloaded âListenElement()â is ambiguous<br />
list.cpp:16: note: candidates are: ListenElement::ListenElement()<br />
list.cpp:10: note: ListenElement::ListenElement(ListenElement*, ListenElement*)</p>
<p>Wobei doch klar sein sollte, welcher Konstruktor angesprochen werden soll? Schließlich ist der andere protected. Naja, dann kam ich auf die Idee, mit den Klammern anzugeben, welchen ich denn meine. Aber das ist wohl in die Hose gegangen.</p>
<p>Was soll ich jetzt tun? <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="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1581420</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1581420</guid><dc:creator><![CDATA[Ichbins-Jens]]></dc:creator><pubDate>Sat, 13 Sep 2008 16:33:16 GMT</pubDate></item><item><title><![CDATA[Reply to aha, non-class type, obwohl als Klasse definiert? on Sat, 13 Sep 2008 16:37:24 GMT]]></title><description><![CDATA[<p>Habe jetzt dem jenigen Konstruktor mit leerer Argumentliste einfach noch ein &quot;int a&quot; eingefügt, das aber nicht weiter benutzt wird. dann funktioniert der Aufruf &quot;ListenElement le(0);&quot;<br />
Aber sonderlich elegant ist das nicht, was meint Ihr?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1581424</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1581424</guid><dc:creator><![CDATA[Ichbins-Jens]]></dc:creator><pubDate>Sat, 13 Sep 2008 16:37:24 GMT</pubDate></item><item><title><![CDATA[Reply to aha, non-class type, obwohl als Klasse definiert? on Sat, 13 Sep 2008 16:39:48 GMT]]></title><description><![CDATA[<p>Ichbins-Jens schrieb:</p>
<blockquote>
<p>Wobei doch klar sein sollte, welcher Konstruktor angesprochen werden soll? Schließlich ist der andere protected. Naja, dann kam ich auf die Idee, mit den Klammern anzugeben, welchen ich denn meine. Aber das ist wohl in die Hose gegangen.</p>
</blockquote>
<p>Nein, so klug ist der Compiler nicht und darf er auch nicht sein. Du hast nämlich zweimal den Default-Konstruktor.<br />
<code>ListenElement(ListenElement *p=0, ListenElement *n=0);</code><br />
Kann man auch sehen als:<br />
<code>ListenElement();</code></p>
<p>Also am besten diese Defaultwerte rausnehmen:<br />
<code>ListenElement(ListenElement *p, ListenElement *n);</code></p>
<p>Grundsätzlich hast du den Konstruktor mit den Defaultwerten bereits als Konstruktor, musst dies somit nicht noch einmal angeben <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /></p>
<p>Grüssli</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1581427</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1581427</guid><dc:creator><![CDATA[Dravere]]></dc:creator><pubDate>Sat, 13 Sep 2008 16:39:48 GMT</pubDate></item><item><title><![CDATA[Reply to aha, non-class type, obwohl als Klasse definiert? on Sat, 13 Sep 2008 16:47:31 GMT]]></title><description><![CDATA[<p>Herzlichen Dank, schon wieder Stunden der Verzweiflung gespart <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="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1581429</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1581429</guid><dc:creator><![CDATA[Ichbins-Jens]]></dc:creator><pubDate>Sat, 13 Sep 2008 16:47:31 GMT</pubDate></item></channel></rss>