<?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[CallByName in Visual C++]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>gibt es eine CallByName-Methode in Visual C++? Also eine Methode die eine bestimmte Methode mit dem Namen aus einem string aufruft?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/174391/callbyname-in-visual-c</link><generator>RSS for Node</generator><lastBuildDate>Sat, 25 Apr 2026 14:55:32 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/174391.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 26 Feb 2007 12:51:06 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CallByName in Visual C++ on Mon, 26 Feb 2007 12:51:06 GMT]]></title><description><![CDATA[<p>Hallo zusammen,</p>
<p>gibt es eine CallByName-Methode in Visual C++? Also eine Methode die eine bestimmte Methode mit dem Namen aus einem string aufruft?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1235698</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235698</guid><dc:creator><![CDATA[Meyer123]]></dc:creator><pubDate>Mon, 26 Feb 2007 12:51:06 GMT</pubDate></item><item><title><![CDATA[Reply to CallByName in Visual C++ on Mon, 26 Feb 2007 12:58:35 GMT]]></title><description><![CDATA[<p>Was willst du denn erreichen? (zur Laufzeit kennt das Programm keine Variablennamen mehr, nur noch die Adressen)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1235705</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235705</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 26 Feb 2007 12:58:35 GMT</pubDate></item><item><title><![CDATA[Reply to CallByName in Visual C++ on Mon, 26 Feb 2007 13:09:41 GMT]]></title><description><![CDATA[<p>Nein, sowas gibts nicht.<br />
Kann man sich aber zusammen bauen.<br />
Ich hab hier mal ein Beispiel gemacht für std. c++<br />
Kann man entsprechend auf MFC umbauen</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;map&gt;
#include &lt;string&gt;
using namespace std;

void func1()
{
	cout &lt;&lt; &quot;'func1' aufgerufen&quot; &lt;&lt; endl;
}

void func2()
{
	cout &lt;&lt; &quot;'func2' aufgerufen&quot; &lt;&lt; endl;
}

void func3()
{
	cout &lt;&lt; &quot;'func3' aufgerufen&quot; &lt;&lt; endl;
}

typedef void (*pFunction)();

int main( int argc, char* argv[] )
{
	map&lt;string, pFunction&gt; functions;
	functions[&quot;f1&quot;] = func1;
	functions[&quot;f2&quot;] = func2;
	functions[&quot;f3&quot;] = func3;

	string action;
	getline(cin, action);
	pFunction f = functions[action];
	if( f )
		f();
	else
		cout &lt;&lt; &quot;Funktion nicht gefunden!&quot; &lt;&lt; endl;
     cin.get();
     return EXIT_SUCCESS;
}
</code></pre>
<p>Wenn man nun in der Konsole f1, f2 oder f3 eingibt, dann wird die entsprechende Funktion aufgerufen</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1235717</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235717</guid><dc:creator><![CDATA[Airdamn]]></dc:creator><pubDate>Mon, 26 Feb 2007 13:09:41 GMT</pubDate></item><item><title><![CDATA[Reply to CallByName in Visual C++ on Mon, 26 Feb 2007 13:10:37 GMT]]></title><description><![CDATA[<p>Also ich kenne diese Methode aus Visual Basic 6... da ruft man einfach CallByName(Funktionsname, Parameter) auf und dann wird die entsprechende Methode mit dem Namen aufgerufen.</p>
<p>Ich möchte einfach, dass jemand auf der Konsole z.B. Summe eingeben kann oder Multipliziere und dann die entsprechende Methode mit dem Namen Summe bzw. Multipliziere aufgerufen wird.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1235718</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235718</guid><dc:creator><![CDATA[Meyer123]]></dc:creator><pubDate>Mon, 26 Feb 2007 13:10:37 GMT</pubDate></item><item><title><![CDATA[Reply to CallByName in Visual C++ on Mon, 26 Feb 2007 13:24:50 GMT]]></title><description><![CDATA[<p>Wenn du sowas brauchst, mußt du es selber bauen (wie das aussehen kann, hat Airdamn angedeutet).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1235726</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235726</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 26 Feb 2007 13:24:50 GMT</pubDate></item><item><title><![CDATA[Reply to CallByName in Visual C++ on Mon, 26 Feb 2007 13:30:42 GMT]]></title><description><![CDATA[<p>Wenn Du daran denkst eine Makro Sprache zu bauen, dann lohnt sich ein Blick auf die Mögichkeit VB-Script zu hosten.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1235731</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235731</guid><dc:creator><![CDATA[Martin Richter]]></dc:creator><pubDate>Mon, 26 Feb 2007 13:30:42 GMT</pubDate></item><item><title><![CDATA[Reply to CallByName in Visual C++ on Mon, 26 Feb 2007 13:49:27 GMT]]></title><description><![CDATA[<p>Danke erstmal für die Antworten...</p>
<p>Ich wollte es jetzt mal so machen wie Airdamn es vorgeschlagen hat... meine Funktionen sollen aber noch einen Parameter übergeben bekommen... Nun habe ich folgendes gemacht...</p>
<pre><code class="language-cpp">class CTest {

  public:
    void Summe(int iWert);

  private:
    typedef void (CTest::* pFunction)(int);
    typedef std::map&lt;CString, pFunction&gt; functions;

    void Init();

    functions m_functions;
}
</code></pre>
<p>Dann habe ich noch folgendes gemacht:</p>
<pre><code class="language-cpp">void CTest::Init() {
  m_functions[&quot;Summe&quot;] = &amp;CTest::Summe;
}
</code></pre>
<p>Um anschließenden in einer Klassenmethode von CTest folgendes aufzurufen:</p>
<pre><code class="language-cpp">pFunction test = m_functions[&quot;Summe&quot;];
</code></pre>
<p>Nun ist das Problem wenn ich test(5) aufrufe gibt es einen Fehler:</p>
<p>Ausdruck ergibt keine Funktion, die 1 Argumente übernimmt</p>
<p>Wieso?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1235753</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235753</guid><dc:creator><![CDATA[Meyer123]]></dc:creator><pubDate>Mon, 26 Feb 2007 13:49:27 GMT</pubDate></item><item><title><![CDATA[Reply to CallByName in Visual C++ on Mon, 26 Feb 2007 13:56:56 GMT]]></title><description><![CDATA[<p>Methodenzeiger sind etwas schwieriger zu handhaben (und benötigen vor allem immer ein this-Objekt, auf dem sie arbeiten könnten) - wenn es geht, solltest du besser darauf verzichten und stattdessen &quot;normale&quot; Funktionen verwenden:</p>
<pre><code class="language-cpp">void Summe(int);

class CTest
{
public:
  typedef void (*func)(int);
  map&lt;string,func&gt; functions;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1235760</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235760</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Mon, 26 Feb 2007 13:56:56 GMT</pubDate></item><item><title><![CDATA[Reply to CallByName in Visual C++ on Mon, 26 Feb 2007 14:08:17 GMT]]></title><description><![CDATA[<p>Also ein this Objekt habe ich ja schon :)... aber wie bringe ich den nun meinen Funktionszeiger und mein this Zeiger dazu die Funktion aufzurufen :)... ich würde das schon gerne &quot;verstehen&quot; bzw. mal ausprobieren :).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1235769</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235769</guid><dc:creator><![CDATA[Meyer123]]></dc:creator><pubDate>Mon, 26 Feb 2007 14:08:17 GMT</pubDate></item><item><title><![CDATA[Reply to CallByName in Visual C++ on Mon, 26 Feb 2007 14:12:18 GMT]]></title><description><![CDATA[<p>Ich habs jetzt mal so gemacht</p>
<pre><code class="language-cpp">(this-&gt;*test)(5);
</code></pre>
<p>Und es läuft :D... Ist das so nun eine eher schlechte Lösung?!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1235776</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1235776</guid><dc:creator><![CDATA[Meyer123]]></dc:creator><pubDate>Mon, 26 Feb 2007 14:12:18 GMT</pubDate></item></channel></rss>