<?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[Überladen von Funktionen]]></title><description><![CDATA[<pre><code>void F(int i) {
  static_cast&lt;void&gt;(i);
}

class Test {
public:
  void F() {
    F(1);  // 'Test::F': Funktion akzeptiert keine 1 Argumente
    // ::F(1);  // OK
  }
};
</code></pre>
<p>Aus welchem Grund benötige ich den <strong>::Operator</strong>, um auf <strong>F(int)</strong> von <strong>class T</strong> aus zuzugreifen? Funktionsüberladung scheint nicht aus Klassen heraus zu funktionieren, weshalb?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/320192/überladen-von-funktionen</link><generator>RSS for Node</generator><lastBuildDate>Fri, 24 Jul 2026 08:28:14 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/320192.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 19 Sep 2013 18:24:16 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Überladen von Funktionen on Thu, 19 Sep 2013 18:24:16 GMT]]></title><description><![CDATA[<pre><code>void F(int i) {
  static_cast&lt;void&gt;(i);
}

class Test {
public:
  void F() {
    F(1);  // 'Test::F': Funktion akzeptiert keine 1 Argumente
    // ::F(1);  // OK
  }
};
</code></pre>
<p>Aus welchem Grund benötige ich den <strong>::Operator</strong>, um auf <strong>F(int)</strong> von <strong>class T</strong> aus zuzugreifen? Funktionsüberladung scheint nicht aus Klassen heraus zu funktionieren, weshalb?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2353866</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2353866</guid><dc:creator><![CDATA[Tomahawk]]></dc:creator><pubDate>Thu, 19 Sep 2013 18:24:16 GMT</pubDate></item><item><title><![CDATA[Reply to Überladen von Funktionen on Thu, 19 Sep 2013 18:38:21 GMT]]></title><description><![CDATA[<p>Du Überlädst hier in keinster Weise die Funktion F( int i ).<br />
Die Funktion F() inerhalb der Klasse hat nämlich einen anderen, vollständig qualifizierten Namen: &quot;Test::F().<br />
Das Schlagwort, das du suchst ist Gültigkeitsbereich und Sichtbarkeit.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2353873</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2353873</guid><dc:creator><![CDATA[hansi22]]></dc:creator><pubDate>Thu, 19 Sep 2013 18:38:21 GMT</pubDate></item><item><title><![CDATA[Reply to Überladen von Funktionen on Thu, 19 Sep 2013 18:42:49 GMT]]></title><description><![CDATA[<p>Überladung funktioniert immer nur innerhalb eines Scopes, deshalb wird für den Aufruf von F in der Klasse, nachdem bereits eine Funktion namens F in der Klasse gefunden wurde, nicht mehr weiter außerhalb nach anderen F's gesucht.</p>
<p>BTW:</p>
<pre><code class="language-cpp">// urgs
void F(int i) {
  static_cast&lt;void&gt;(i);
}

// ==&gt;

void F(int) {
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2353877</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2353877</guid><dc:creator><![CDATA[Bashar]]></dc:creator><pubDate>Thu, 19 Sep 2013 18:42:49 GMT</pubDate></item><item><title><![CDATA[Reply to Überladen von Funktionen on Thu, 19 Sep 2013 18:46:38 GMT]]></title><description><![CDATA[<p>Bashar schrieb:</p>
<blockquote>
<p>Überladung funktioniert immer nur innerhalb eines Scopes ...</p>
</blockquote>
<p>Danke, das war mir nicht bekannt!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2353878</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2353878</guid><dc:creator><![CDATA[Tomahawk]]></dc:creator><pubDate>Thu, 19 Sep 2013 18:46:38 GMT</pubDate></item><item><title><![CDATA[Reply to Überladen von Funktionen on Thu, 19 Sep 2013 18:54:31 GMT]]></title><description><![CDATA[<p>Bashar schrieb:</p>
<blockquote>
<p>Überladung funktioniert immer nur innerhalb eines Scopes, deshalb wird für den Aufruf von F in der Klasse, nachdem bereits eine Funktion namens F in der Klasse gefunden wurde, nicht mehr weiter außerhalb nach anderen F's gesucht.</p>
</blockquote>
<p>Die könnte allerdings per adl gefunden werden.</p>
<pre><code class="language-cpp">struct foo : Test
{
    void bar() { F(*this); } // findet Test::f per unqualiziertem Lookup und ::F per adl
    operator int() { return 42; }
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2353879</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2353879</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Thu, 19 Sep 2013 18:54:31 GMT</pubDate></item><item><title><![CDATA[Reply to Überladen von Funktionen on Fri, 20 Sep 2013 10:37:24 GMT]]></title><description><![CDATA[<p>camper schrieb:</p>
<blockquote>
<p>Bashar schrieb:</p>
<blockquote>
<p>Überladung funktioniert immer nur innerhalb eines Scopes, deshalb wird für den Aufruf von F in der Klasse, nachdem bereits eine Funktion namens F in der Klasse gefunden wurde, nicht mehr weiter außerhalb nach anderen F's gesucht.</p>
</blockquote>
<p>Die könnte allerdings per adl gefunden werden.</p>
<pre><code class="language-cpp">struct foo : Test
{
    void bar() { F(*this); } // findet Test::f per unqualiziertem Lookup und ::F per adl
    operator int() { return 42; }
};
</code></pre>
</blockquote>
<p>Ich glaube, das ist nicht ganz richtig. Ausprobiert habe ich es jetzt nicht, aber §3.4.2/3 sagt, dass wenn die &quot;normale&quot; unqualifizierte Namenssuche (also ohne ADL) eine Elementfunktion findet, dass dann das per ADL produzierte &quot;lookup set&quot; leer ist. So, wie ich das verstehe, schließt das auch Elementfunktionen aus Basisklassen ein. <a href="http://ideone.com/adk8Mm" rel="nofollow">Dieser Test bestätigt das</a>.</p>
<p>In Deinem Fall ist Test::F ja eine Elementfunktion, die per &quot;normalem&quot; Namelookup gefunden wird. Demnach wäre ::F nicht in dem von per ADL produzierten &quot;lookup set&quot;.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2353982</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2353982</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Fri, 20 Sep 2013 10:37:24 GMT</pubDate></item><item><title><![CDATA[Reply to Überladen von Funktionen on Fri, 20 Sep 2013 10:39:23 GMT]]></title><description><![CDATA[<p>ah, stimmt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2353984</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2353984</guid><dc:creator><![CDATA[camper]]></dc:creator><pubDate>Fri, 20 Sep 2013 10:39:23 GMT</pubDate></item></channel></rss>