<?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[Problem bei Funktionszeiger!]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich habe eine Klasse Cmd, in der ich Kommandos erzeuge. Ein Attribut der Klasse ist als Funktionszeiger implementiert. Dieser Funktionszeiger soll auf die für den Kommando vorgesehende Funktion zugewiesen werden. In meinem Fall übergebe ich einem Objekt der klasse Cmd eine Funktion der Klasse Flash_cmd(diesse Klasse besitzt Funktionen zur Ansteuerung eines Flashspeichers). Die Klasse Flash-Cmds ist als Singleton-pattern implementiert und die Übergabe von Funktionen aus der Klasse Flash_cmds an den Funktionszeiger vom Objekt der Klasse Cmd funktioniert nicht:</p>
<p><em>Fehlermeldung:<br />
Fehler 1 error C3867: &quot;Flash_cmds::setStartaddr&quot;: Dem Funktionsaufruf fehlt die Argumentliste. Verwenden Sie &quot;&amp;Flash_cmds::setStartaddr&quot;, um einen Zeiger auf den Member zu erstellen. 17</em></p>
<p><strong>main.cpp</strong></p>
<pre><code class="language-cpp">#define flash_cmds Flash_cmds::getInstance()
void flash_init_52401 (Flash&amp; fl);
void test(const int&amp; ha){std::cout&lt;&lt;&quot;hallo&quot;&lt;&lt;ha;};

int main()
{
    Flash flash;

    Cmd* mass_erase= new Cmd(&quot;set_startaddr&quot;, 1, 1, Flash_cmds::getInstance().setStartaddr);
    mass_erase-&gt;Execute();
</code></pre>
<p><strong>Cmd.h</strong></p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &quot;string.h&quot;

#pragma once

class Cmd
{
private:

    std::string cmd_name;
    std::string cmd_arg;
    int cmd_id;
    int cmd_argcount;
    void (*cmd_exe)(void);
    void (*cmd_exe_arg)(const int&amp; t );

public:
    Cmd(void);
    ~Cmd(void);
    Cmd(std::string name, int id, int argcnt, void (*execute_function)(void));
    Cmd(std::string name, int id, int argcnt, void (*execute_function)(const int&amp;));

    std::string GetName(void)const;
    int GetArgCount(void)const;

    void setArg(const std::string&amp; arg);

    void Execute (void) const;

    bool operator==(const std::string&amp; cmd)const
    {
        return(this-&gt;GetName()==cmd);
    }
};
</code></pre>
<p><strong>Cmd.cpp</strong></p>
<pre><code class="language-cpp">#include &quot;Cmd.h&quot;

Cmd::Cmd(void)
{
}

Cmd::Cmd(const std::string name, const int id, const int argcnt,void (*execute_function)(void) )
: cmd_name(name), cmd_id(id), cmd_argcount(argcnt), cmd_exe(execute_function)
{
    if (argcnt&lt;0)
    {   
        std::cout&lt;&lt;&quot;Ungueltige Anzahl von Argumenten&quot;&lt;&lt;std::endl;
        cmd_argcount=0;
    }

}

Cmd::Cmd(const std::string name, const int id, const int argcnt, void (*execute_function)(const int&amp; t) )
: cmd_name(name), cmd_id(id), cmd_argcount(argcnt),cmd_exe_arg(execute_function)
{
    if (argcnt&lt;0)
    {   
        std::cout&lt;&lt;&quot;Ungueltige Anzahl von Argumenten&quot;&lt;&lt;std::endl;
        cmd_argcount=0;
    }

}

Cmd::~Cmd(void)
{
}

std::string Cmd::GetName (void) const
{
    return Cmd::cmd_name;
}

int Cmd::GetArgCount (void) const
{
    return Cmd::cmd_argcount;
}

void Cmd::Execute (void) const
{
    if(cmd_argcount==1)
        cmd_exe_arg(500);
    else
        cmd_exe();
}

void Cmd::setArg(const std::string&amp; arg)
{
    cmd_arg=arg;
}
</code></pre>
<p><strong>Flash_cmds</strong></p>
<pre><code class="language-cpp">//Die Klasse Flash-CMD ist als Singleton-Pattern implementiert. Es kann nur ein Objekt einer 
//Klasse erstellt werden

//#include flash.h
#include &lt;iostream&gt;
#include &lt;fstream&gt; //für ofstream
#include &lt;sstream&gt;
#include &lt;string&gt;
#include &quot;Flash.h&quot;
#include &quot;headertest.h&quot;
//#include &quot;help.h&quot; //für read_file
#pragma once

class Flash_cmds
{

private:
    Flash flash;
    static Flash_cmds* OBJ;
    bool prog_data_content;
    long int *flashbuf;
    long int *filebuf;
    long int * progcontent_arr;
    long int * readcontent_arr;
    char rchar[40];
    int startaddr;
    int endaddr;
    int flashmode;
    bool fdebug;
    std::ofstream prog_file;
    Flash_cmds(void)
    {
        progcontent_arr=0;
        readcontent_arr=0;
        std::cout &lt;&lt; &quot;test \n&quot;;
    }
    Flash_cmds(const Flash_cmds&amp;);  //nicht kopierbar
    ~Flash_cmds(void);
//Konstante für Prog-Content
     static const int chess=0;
     static const int invchess=1; 
     static const int address=2; 
     static const int array0=3;
     static const int array1=4; 
     static const int data_content=5;

//Konstante für Flashmode
     static const int flash12k=12;
     static const int flash8k=8; 
     static const int flash4k=4; 

public:

    static Flash_cmds&amp; getInstance();
    static void destroy();

    //Get &amp; Set Methoden für Attribute

    int getStartaddr() const;
    int getEndaddr() const;
    int getFlashmode()const;

    void setFlash(const Flash&amp; fl);
    void setStartaddr(const int&amp; saddr);
    void setEndaddr(const int&amp; eaddr);

    void setProgcontent(const int&amp; pgcont);
    void setFlashmode(const int&amp; fmode);

    void start_read(void);
    void start_program(void);
    void start_masserase(void);
    void start_verify(void);
    void start_compare(void);
};
</code></pre>
<p><strong>Vielen Dank im Voraus!</strong></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/290195/problem-bei-funktionszeiger</link><generator>RSS for Node</generator><lastBuildDate>Tue, 18 Aug 2026 00:21:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/290195.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 21 Jul 2011 07:59:46 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 07:59:46 GMT]]></title><description><![CDATA[<p>Hallo!</p>
<p>Ich habe eine Klasse Cmd, in der ich Kommandos erzeuge. Ein Attribut der Klasse ist als Funktionszeiger implementiert. Dieser Funktionszeiger soll auf die für den Kommando vorgesehende Funktion zugewiesen werden. In meinem Fall übergebe ich einem Objekt der klasse Cmd eine Funktion der Klasse Flash_cmd(diesse Klasse besitzt Funktionen zur Ansteuerung eines Flashspeichers). Die Klasse Flash-Cmds ist als Singleton-pattern implementiert und die Übergabe von Funktionen aus der Klasse Flash_cmds an den Funktionszeiger vom Objekt der Klasse Cmd funktioniert nicht:</p>
<p><em>Fehlermeldung:<br />
Fehler 1 error C3867: &quot;Flash_cmds::setStartaddr&quot;: Dem Funktionsaufruf fehlt die Argumentliste. Verwenden Sie &quot;&amp;Flash_cmds::setStartaddr&quot;, um einen Zeiger auf den Member zu erstellen. 17</em></p>
<p><strong>main.cpp</strong></p>
<pre><code class="language-cpp">#define flash_cmds Flash_cmds::getInstance()
void flash_init_52401 (Flash&amp; fl);
void test(const int&amp; ha){std::cout&lt;&lt;&quot;hallo&quot;&lt;&lt;ha;};

int main()
{
    Flash flash;

    Cmd* mass_erase= new Cmd(&quot;set_startaddr&quot;, 1, 1, Flash_cmds::getInstance().setStartaddr);
    mass_erase-&gt;Execute();
</code></pre>
<p><strong>Cmd.h</strong></p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &quot;string.h&quot;

#pragma once

class Cmd
{
private:

    std::string cmd_name;
    std::string cmd_arg;
    int cmd_id;
    int cmd_argcount;
    void (*cmd_exe)(void);
    void (*cmd_exe_arg)(const int&amp; t );

public:
    Cmd(void);
    ~Cmd(void);
    Cmd(std::string name, int id, int argcnt, void (*execute_function)(void));
    Cmd(std::string name, int id, int argcnt, void (*execute_function)(const int&amp;));

    std::string GetName(void)const;
    int GetArgCount(void)const;

    void setArg(const std::string&amp; arg);

    void Execute (void) const;

    bool operator==(const std::string&amp; cmd)const
    {
        return(this-&gt;GetName()==cmd);
    }
};
</code></pre>
<p><strong>Cmd.cpp</strong></p>
<pre><code class="language-cpp">#include &quot;Cmd.h&quot;

Cmd::Cmd(void)
{
}

Cmd::Cmd(const std::string name, const int id, const int argcnt,void (*execute_function)(void) )
: cmd_name(name), cmd_id(id), cmd_argcount(argcnt), cmd_exe(execute_function)
{
    if (argcnt&lt;0)
    {   
        std::cout&lt;&lt;&quot;Ungueltige Anzahl von Argumenten&quot;&lt;&lt;std::endl;
        cmd_argcount=0;
    }

}

Cmd::Cmd(const std::string name, const int id, const int argcnt, void (*execute_function)(const int&amp; t) )
: cmd_name(name), cmd_id(id), cmd_argcount(argcnt),cmd_exe_arg(execute_function)
{
    if (argcnt&lt;0)
    {   
        std::cout&lt;&lt;&quot;Ungueltige Anzahl von Argumenten&quot;&lt;&lt;std::endl;
        cmd_argcount=0;
    }

}

Cmd::~Cmd(void)
{
}

std::string Cmd::GetName (void) const
{
    return Cmd::cmd_name;
}

int Cmd::GetArgCount (void) const
{
    return Cmd::cmd_argcount;
}

void Cmd::Execute (void) const
{
    if(cmd_argcount==1)
        cmd_exe_arg(500);
    else
        cmd_exe();
}

void Cmd::setArg(const std::string&amp; arg)
{
    cmd_arg=arg;
}
</code></pre>
<p><strong>Flash_cmds</strong></p>
<pre><code class="language-cpp">//Die Klasse Flash-CMD ist als Singleton-Pattern implementiert. Es kann nur ein Objekt einer 
//Klasse erstellt werden

//#include flash.h
#include &lt;iostream&gt;
#include &lt;fstream&gt; //für ofstream
#include &lt;sstream&gt;
#include &lt;string&gt;
#include &quot;Flash.h&quot;
#include &quot;headertest.h&quot;
//#include &quot;help.h&quot; //für read_file
#pragma once

class Flash_cmds
{

private:
    Flash flash;
    static Flash_cmds* OBJ;
    bool prog_data_content;
    long int *flashbuf;
    long int *filebuf;
    long int * progcontent_arr;
    long int * readcontent_arr;
    char rchar[40];
    int startaddr;
    int endaddr;
    int flashmode;
    bool fdebug;
    std::ofstream prog_file;
    Flash_cmds(void)
    {
        progcontent_arr=0;
        readcontent_arr=0;
        std::cout &lt;&lt; &quot;test \n&quot;;
    }
    Flash_cmds(const Flash_cmds&amp;);  //nicht kopierbar
    ~Flash_cmds(void);
//Konstante für Prog-Content
     static const int chess=0;
     static const int invchess=1; 
     static const int address=2; 
     static const int array0=3;
     static const int array1=4; 
     static const int data_content=5;

//Konstante für Flashmode
     static const int flash12k=12;
     static const int flash8k=8; 
     static const int flash4k=4; 

public:

    static Flash_cmds&amp; getInstance();
    static void destroy();

    //Get &amp; Set Methoden für Attribute

    int getStartaddr() const;
    int getEndaddr() const;
    int getFlashmode()const;

    void setFlash(const Flash&amp; fl);
    void setStartaddr(const int&amp; saddr);
    void setEndaddr(const int&amp; eaddr);

    void setProgcontent(const int&amp; pgcont);
    void setFlashmode(const int&amp; fmode);

    void start_read(void);
    void start_program(void);
    void start_masserase(void);
    void start_verify(void);
    void start_compare(void);
};
</code></pre>
<p><strong>Vielen Dank im Voraus!</strong></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2095865</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095865</guid><dc:creator><![CDATA[pat.de]]></dc:creator><pubDate>Thu, 21 Jul 2011 07:59:46 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 08:06:40 GMT]]></title><description><![CDATA[<p>Was spricht denn dagegen, den Adress-Operator zu verwenden wies in der Fehlermeldung angegeben ist?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2095867</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095867</guid><dc:creator><![CDATA[Bonzy]]></dc:creator><pubDate>Thu, 21 Jul 2011 08:06:40 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 08:27:19 GMT]]></title><description><![CDATA[<p>das funktioniert leider auch nicht. ich habe in meinem quellcode den ich oben gepostet habe in der main die funktion test mal probiert zu übergeben und das funktioniert ohne Probleme...per adresse sowie per variable. liegt das problem evtl beim singleton-pattern?</p>
<p><strong>Fehler:<br />
Fehler 1 error C2276: '&amp;': Ungültige Operation auf Ausdruck einer gebundenen Memberfunktion</strong></p>
<p><strong>Code</strong></p>
<pre><code class="language-cpp">Cmd* mass_erase= new Cmd(&quot;set_startaddr&quot;, 1, 1, &amp;Flash_cmds::getInstance().setStartaddr);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2095876</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095876</guid><dc:creator><![CDATA[pat.de]]></dc:creator><pubDate>Thu, 21 Jul 2011 08:27:19 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 08:40:06 GMT]]></title><description><![CDATA[<p>Der Aufruf passt auch nicht zum Konstruktor der Klasse Cmd. Der nimmt nur freie Funktionszeiger entgegen, keine Zeiger auf Member Funktionen.</p>
<p>Was genau hast du denn eigentlich vor?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2095883</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095883</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Thu, 21 Jul 2011 08:40:06 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 09:00:00 GMT]]></title><description><![CDATA[<p>ich will einen parser bauen. über das netzwerk empfangene strings werden mit den objekten der klasse cmd verglichen. naja, und jeder befehl(objekt der klasse cmd) verweist auf eine für den befehl zugewiesende funktion, die mit execute dann ausgeführt wird.</p>
<p>also: string wird empfangen -&gt; string wird mit befehlen der klasse cmd verglichen -&gt; die zum zum befehl passende funktion wird aufgerufen...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2095907</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095907</guid><dc:creator><![CDATA[pat.de]]></dc:creator><pubDate>Thu, 21 Jul 2011 09:00:00 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 09:22:12 GMT]]></title><description><![CDATA[<p><a href="http://pat.de" rel="nofollow">pat.de</a> schrieb:</p>
<blockquote>
<p>ich will einen parser bauen. über das netzwerk empfangene strings werden mit den objekten der klasse cmd verglichen. naja, und jeder befehl(objekt der klasse cmd) verweist auf eine für den befehl zugewiesende funktion, die mit execute dann ausgeführt wird.</p>
<p>also: string wird empfangen -&gt; string wird mit befehlen der klasse cmd verglichen -&gt; die zum zum befehl passende funktion wird aufgerufen...</p>
</blockquote>
<p>Eine Möglichkeit das zu bewerkstelligen wären Funktionsobjekte oder boost::function, aber bleiben wir mal bei deiner Lösung. Um die Adresse einer Memberfunktion zu übergeben brauchst du kein Objekt der Klasse, sondern nur den Typen. Erst beim Aufruf durch den Funktionszeiger musst du ein gültiges Objekt bereitstellen:</p>
<pre><code class="language-cpp">struct Cmd
{
   ...
   // Konstruktor für Flash Memberfunktion 
   Cmd( std::string name, 
        int id, 
        int argcnt, 
        void (Flash::*execute_function)() );
   ...
}

int main()
{
   Flash Flash;
   Cmd c( &quot;start_read&quot;, 1, 1, &amp;Flash::start_read );
}
</code></pre>
<p>Gefällt mir allerdings nicht, für den Memberfunktionsauf musst du dem Cmd Objekt noch eine Flash Instanz in die Hand drücken, sonst weiß es nicht, auf welchem Objekt es die Funktion aufrufen soll. Und ein Cmd Objekt für verschiedene Funktionen (member/non-member) mit unterschiedlich vielen Parametern finde ich auch nicht toll. Damit wären wir dann bei boost::function oder müssten uns selbst was basteln (vermutlich mit Templates und Vererbung).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2095918</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095918</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Thu, 21 Jul 2011 09:22:12 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 09:39:50 GMT]]></title><description><![CDATA[<p>Vielen Dank für deine Hilfe....</p>
<blockquote>
<p>Gefällt mir allerdings nicht, für den Memberfunktionsauf musst du dem Cmd Objekt noch eine Flash Instanz in die Hand drücken, sonst weiß es nicht, auf welchem Objekt es die Funktion aufrufen soll. Und ein Cmd Objekt für verschiedene Funktionen (member/non-member) mit unterschiedlich vielen Parametern finde ich auch nicht toll.</p>
</blockquote>
<p>da müsste ich auf jedenfall variabel bleiben. ich hab noch andere memberfunktionen aus anderen klassen, die ich dann einem befehl zuweisen will. (z.B. DAC/ADC-Funktionen)</p>
<blockquote>
<p>Damit wären wir dann bei boost::function</p>
</blockquote>
<p>hab einen mikrocontroller auf dem embedded linux läuft und kann bis jetzt nur auf die standart libary zugreifen oder ist das kein problem die libary zu erweitern?</p>
<blockquote>
<p>oder müssten uns selbst was basteln (vermutlich mit Templates und Vererbung).</p>
</blockquote>
<p>das wäre vllt die bessere option...wenn zitat↑ ein problem darstellt</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2095928</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095928</guid><dc:creator><![CDATA[pat.de]]></dc:creator><pubDate>Thu, 21 Jul 2011 09:39:50 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 09:56:12 GMT]]></title><description><![CDATA[<p>Einzelne Libraries aus Boost sollten auch unter embedded Linux laufen (wenn nicht sogar alle).</p>
<p>Alternativ kannst Du auch z.B. das hier verwenden:<br />
<a href="http://www.codeproject.com/KB/cpp/FastDelegate.aspx" rel="nofollow">http://www.codeproject.com/KB/cpp/FastDelegate.aspx</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2095938</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095938</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Thu, 21 Jul 2011 09:56:12 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 10:07:57 GMT]]></title><description><![CDATA[<p>Das Problem ist nicht das Zielsystem, sondern der Compiler. Wenn der mit boost klarkommt enthält das Executable sämtlichen ausführbaren Code, da spielt das Target keine Rolle (vorausgesetzt, man linkt statisch).<br />
Die Frage ist nur, ob deine Vorgaben die Benutzung externer Bibliotheken erlauben, oder darfst du benutzen, was du willst?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2095945</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095945</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Thu, 21 Jul 2011 10:07:57 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 10:18:51 GMT]]></title><description><![CDATA[<blockquote>
<p>Die Frage ist nur, ob deine Vorgaben die Benutzung externer Bibliotheken erlauben, oder darfst du benutzen, was du willst?</p>
</blockquote>
<p>ich kann mich da ganz frei bewegen, aber mir persönlich wäre es lieber auf die standard libary zuzugreifen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2095951</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095951</guid><dc:creator><![CDATA[pat.de]]></dc:creator><pubDate>Thu, 21 Jul 2011 10:18:51 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 10:44:05 GMT]]></title><description><![CDATA[<p><a href="http://pat.de" rel="nofollow">pat.de</a> schrieb:</p>
<blockquote>
<blockquote>
<p>Die Frage ist nur, ob deine Vorgaben die Benutzung externer Bibliotheken erlauben, oder darfst du benutzen, was du willst?</p>
</blockquote>
<p>ich kann mich da ganz frei bewegen, aber mir persönlich wäre es lieber auf die standard libary zuzugreifen.</p>
</blockquote>
<p>Ev. ist deine Kompiler / Library schon so weit, dass er TR1 Dinge von C++11 unterstützt, z.B. std::function&lt;...&gt; bzw. std::tr1::function&lt;...&gt;</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2095969</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095969</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Thu, 21 Jul 2011 10:44:05 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 11:00:04 GMT]]></title><description><![CDATA[<p><a href="http://pat.de" rel="nofollow">pat.de</a> schrieb:</p>
<blockquote>
<pre><code class="language-cpp">Cmd* mass_erase= new Cmd(&quot;set_startaddr&quot;, 1, 1, &amp;Flash_cmds::getInstance().setStartaddr);
</code></pre>
</blockquote>
<p>Da holst du dir die addresse von einer funktion einer instanz die du vom statischem context entnimmst.<br />
Ich würde mal sage, wenn setStartAddr eine funktion von Flash_cmds ist: <code>&amp;Flash_cmds::setStartAddr()</code><br />
Dann kannst du das so aufrufen:<br />
<code>(Flash_cmds::getInstance()-&gt;*setStartAddr)(arugumentenliste wie gewohnt);</code></p>
<p><a href="http://www.parashift.com/c++-faq-lite/pointers-to-members.html" rel="nofollow">http://www.parashift.com/c++-faq-lite/pointers-to-members.html</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2095979</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2095979</guid><dc:creator><![CDATA[lk]]></dc:creator><pubDate>Thu, 21 Jul 2011 11:00:04 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 11:45:09 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">// Abstrakte Basisklasse für alle möglichen Commands
class Command
{
public:
	virtual ~Command()
	{
	}

	void operator()()
	{
		execute();
	}

private:
	virtual void execute() = 0;
};

// Implementation für non-member Funktion mit einem Argument
template&lt;typename ResultType, typename ArgumentType&gt;
struct CommandNM1 : Command
{
	typedef ResultType( *FuncPtr)( ArgumentType );

	ResultType 				Result;
	ArgumentType 			Argument;
	FuncPtr					Function;

	CommandNM1( FuncPtr Func, ArgumentType Arg ) :
		Function( Func ),
		Argument( Arg ),
		Result( ResultType() )
	{
	}

	virtual void execute()
	{
		Result = Function( Argument );
	}
};

// Spezialisierung für non-member Funktionen mit einem Argument und ohne Rückgabewert
template&lt;typename ArgumentType&gt;
struct CommandNM1&lt;void,ArgumentType&gt; : Command
{
	typedef void( *FuncPtr)( ArgumentType );

	ArgumentType 			Argument;
	FuncPtr					Function;

	CommandNM1( FuncPtr Func, ArgumentType Arg ) :
		Function( Func ),
		Argument( Arg )
	{
	}

	virtual void execute()
	{
		Function( Argument );
	}
};

template&lt;typename ResultType, typename ArgumentType&gt;
Command* make_command( ResultType (*Func)( ArgumentType ), ArgumentType Arg )
{
	return new CommandNM1&lt;ResultType,ArgumentType&gt;( Func, Arg );
}

// Implementation für member Funktion mit einem Argument
template&lt;typename ObjectType, typename ResultType, typename ArgumentType&gt;
struct CommandM1 : Command
{
	typedef ResultType( ObjectType::*FuncPtr)( ArgumentType );

	ResultType 				Result;
	ArgumentType 			Argument;
	FuncPtr					Function;
	ObjectType&amp;				Object;

	CommandM1( ObjectType&amp; Obj, FuncPtr Func, ArgumentType Arg ) :
		Function( Func ),
		Object( Obj ),
		Argument( Arg ),
		Result( ResultType() )
	{
	}

	virtual void execute()
	{
		Result = (Object.*Function)( Argument );
	}
};

template&lt;typename ObjectType, typename ResultType, typename ArgumentType&gt;
Command* make_command( ObjectType&amp; Obj, ResultType (ObjectType::*Func)( ArgumentType ), ArgumentType Arg )
{
	return new CommandM1&lt;ObjectType,ResultType,ArgumentType&gt;( Obj, Func, Arg );
}

void x( double y )
{
	int z = 0;
}

int f( double x )
{
	return x;
}

struct t
{
	int f( double x )
	{
		return x;
	}
};

int main()
{
	t theT;
	Command* c1 = make_command( f, 101.101 );
	Command* c2 = make_command( theT, &amp;t::f, 101.101 );
	Command* c3 = make_command( x, 101.101 );

	(*c1)();
	(*c2)();
	(*c3)();
}
</code></pre>
<p>Hab mal was (nur so aus der Hüfte geschossen) gebastelt, was du benutzen könntest. Statt roher Zeiger wären smart pointer toll, eventuell kann man mit boost/TR1::function das noch schöner machen. Aber als Hinweis taugt´s allemal was.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2096023</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2096023</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Thu, 21 Jul 2011 11:45:09 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 11:55:25 GMT]]></title><description><![CDATA[<blockquote>
<p>Ev. ist deine Kompiler / Library schon so weit, dass er TR1 Dinge von C++11 unterstützt, z.B. std::function&lt;...&gt; bzw. std::tr1::function&lt;...&gt;</p>
</blockquote>
<p>ich hab den gcc compiler drauf version 4.4.5</p>
<blockquote>
<p>Da holst du dir die addresse von einer funktion einer instanz die du vom statischem context entnimmst.<br />
Ich würde mal sage, wenn setStartAddr eine funktion von Flash_cmds ist: &amp;Flash_cmds::setStartAddr()<br />
Dann kannst du das so aufrufen:<br />
(Flash_cmds::getInstance()-&gt;*setStartAddr)(arugumentenliste wie gewohnt)</p>
</blockquote>
<p>das klappt nicht so ganz...</p>
<p>also bei</p>
<pre><code class="language-cpp">Cmd* set_startaddr= new Cmd(&quot;set_startaddr&quot;, 1, 1, &amp;Flash_cmds::getInstance()-&gt;*setStartaddr);
</code></pre>
<p>kommt der fehler: <em>Fehler 1 error C2065: 'setStartaddr': nichtdeklarierter Bezeichner</em></p>
<p>ist das so richtig implementiert....</p>
<p><strong>Cmd.h</strong></p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &quot;string.h&quot;
#include &quot;Flash_cmds.h&quot;

#pragma once

class Cmd
{
private:

	std::string cmd_name;
	std::string cmd_arg;
	int cmd_id;
	int cmd_argcount;
	void (*cmd_exe)(void);
	void (Flash_cmds::*cmd_exe_arg)(const int&amp; t );

public:
	Cmd(void);
	~Cmd(void);
	Cmd(std::string name, int id, int argcnt, void (*execute_function)(void));
	Cmd(std::string name, int id, int argcnt, void (Flash_cmds::*execute_function)(const int&amp;));

	std::string GetName(void)const;
	int GetArgCount(void)const;

	void setArg(const std::string&amp; arg);

	void Execute (void) const;

	bool operator==(const std::string&amp; cmd)const
	{
		return(this-&gt;GetName()==cmd);
	}
};
</code></pre>
<p><strong>Cmd.cpp</strong></p>
<pre><code class="language-cpp">#include &quot;Cmd.h&quot;

Cmd::Cmd(void)
{
}

Cmd::Cmd(const std::string name, const int id, const int argcnt,void (*execute_function)(void) )
: cmd_name(name), cmd_id(id), cmd_argcount(argcnt), cmd_exe(execute_function)
{
	if (argcnt&lt;0)
	{	
		std::cout&lt;&lt;&quot;Ungueltige Anzahl von Argumenten&quot;&lt;&lt;std::endl;
		cmd_argcount=0;
	}

}

Cmd::Cmd(const std::string name, const int id, const int argcnt, void (Flash_cmds::*execute_function)(const int&amp; t) )
: cmd_name(name), cmd_id(id), cmd_argcount(argcnt),cmd_exe_arg(execute_function)
{
	if (argcnt&lt;0)
	{	
		std::cout&lt;&lt;&quot;Ungueltige Anzahl von Argumenten&quot;&lt;&lt;std::endl;
		cmd_argcount=0;
	}

}

Cmd::~Cmd(void)
{
}

std::string Cmd::GetName (void) const
{
	return Cmd::cmd_name;
}

int Cmd::GetArgCount (void) const
{
	return Cmd::cmd_argcount;
}

void Cmd::Execute (void) const
{
	if(cmd_argcount==1)
		;//cmd_exe_arg(500);
	else
		cmd_exe();
}

void Cmd::setArg(const std::string&amp; arg)
{
	cmd_arg=arg;
}
</code></pre>
<p>...?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2096030</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2096030</guid><dc:creator><![CDATA[pat.de]]></dc:creator><pubDate>Thu, 21 Jul 2011 11:55:25 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 12:08:18 GMT]]></title><description><![CDATA[<blockquote>
<p>ich hab den gcc compiler drauf version 4.4.5</p>
</blockquote>
<p>Der hat AFAIK std::tr1::function&lt;..&gt; drin. Die würde ich auch benutzen!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2096039</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2096039</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Thu, 21 Jul 2011 12:08:18 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 12:14:41 GMT]]></title><description><![CDATA[<p>DocShoe schrieb:</p>
<blockquote>
<pre><code class="language-cpp">// Abstrakte Basisklasse für alle möglichen Commands
class Command
{
public:
	virtual ~Command()
	{
	}

	void operator()()
	{
		execute();
	}

private:
	virtual void execute() = 0;
};

// Implementation für non-member Funktion mit einem Argument
template&lt;typename ResultType, typename ArgumentType&gt;
struct CommandNM1 : Command
{
	typedef ResultType( *FuncPtr)( ArgumentType );

	ResultType 				Result;
	ArgumentType 			Argument;
	FuncPtr					Function;

	CommandNM1( FuncPtr Func, ArgumentType Arg ) :
		Function( Func ),
		Argument( Arg ),
		Result( ResultType() )
	{
	}

	virtual void execute()
	{
		Result = Function( Argument );
	}
};

// Spezialisierung für non-member Funktionen mit einem Argument und ohne Rückgabewert
template&lt;typename ArgumentType&gt;
struct CommandNM1&lt;void,ArgumentType&gt; : Command
{
	typedef void( *FuncPtr)( ArgumentType );

	ArgumentType 			Argument;
	FuncPtr					Function;

	CommandNM1( FuncPtr Func, ArgumentType Arg ) :
		Function( Func ),
		Argument( Arg )
	{
	}

	virtual void execute()
	{
		Function( Argument );
	}
};

template&lt;typename ResultType, typename ArgumentType&gt;
Command* make_command( ResultType (*Func)( ArgumentType ), ArgumentType Arg )
{
	return new CommandNM1&lt;ResultType,ArgumentType&gt;( Func, Arg );
}

// Implementation für member Funktion mit einem Argument
template&lt;typename ObjectType, typename ResultType, typename ArgumentType&gt;
struct CommandM1 : Command
{
	typedef ResultType( ObjectType::*FuncPtr)( ArgumentType );

	ResultType 				Result;
	ArgumentType 			Argument;
	FuncPtr					Function;
	ObjectType&amp;				Object;

	CommandM1( ObjectType&amp; Obj, FuncPtr Func, ArgumentType Arg ) :
		Function( Func ),
		Object( Obj ),
		Argument( Arg ),
		Result( ResultType() )
	{
	}

	virtual void execute()
	{
		Result = (Object.*Function)( Argument );
	}
};

template&lt;typename ObjectType, typename ResultType, typename ArgumentType&gt;
Command* make_command( ObjectType&amp; Obj, ResultType (ObjectType::*Func)( ArgumentType ), ArgumentType Arg )
{
	return new CommandM1&lt;ObjectType,ResultType,ArgumentType&gt;( Obj, Func, Arg );
}

void x( double y )
{
	int z = 0;
}

int f( double x )
{
	return x;
}

struct t
{
	int f( double x )
	{
		return x;
	}
};

int main()
{
	t theT;
	Command* c1 = make_command( f, 101.101 );
	Command* c2 = make_command( theT, &amp;t::f, 101.101 );
	Command* c3 = make_command( x, 101.101 );

	(*c1)();
	(*c2)();
	(*c3)();
}
</code></pre>
<p>Hab mal was (nur so aus der Hüfte geschossen) gebastelt, was du benutzen könntest. Statt roher Zeiger wären smart pointer toll, eventuell kann man mit boost/TR1::function das noch schöner machen. Aber als Hinweis taugt´s allemal was.</p>
</blockquote>
<p>vielen dank docshoe....ich versuch mich da mal durchzuarbeiten. mit templates hab ich noch eher wenig erfahrung.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2096048</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2096048</guid><dc:creator><![CDATA[pat.de]]></dc:creator><pubDate>Thu, 21 Jul 2011 12:14:41 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 13:07:13 GMT]]></title><description><![CDATA[<p>Zeile 32:</p>
<blockquote>
<p>Result( ResultType() )</p>
</blockquote>
<p>was passiert hier???</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2096081</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2096081</guid><dc:creator><![CDATA[pat.de]]></dc:creator><pubDate>Thu, 21 Jul 2011 13:07:13 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 13:18:36 GMT]]></title><description><![CDATA[<p><a href="http://pat.de" rel="nofollow">pat.de</a> schrieb:</p>
<blockquote>
<p>Zeile 32:</p>
<blockquote>
<p>Result( ResultType() )</p>
</blockquote>
<p>was passiert hier???</p>
</blockquote>
<p>Es wird die Member Variable Result mit dem Default-Konstruierten Wert von ResultType initialisiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2096090</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2096090</guid><dc:creator><![CDATA[theta]]></dc:creator><pubDate>Thu, 21 Jul 2011 13:18:36 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 13:38:56 GMT]]></title><description><![CDATA[<p>theta schrieb:</p>
<blockquote>
<p><a href="http://pat.de" rel="nofollow">pat.de</a> schrieb:</p>
<blockquote>
<p>Zeile 32:</p>
<blockquote>
<p>Result( ResultType() )</p>
</blockquote>
<p>was passiert hier???</p>
</blockquote>
<p>Es wird die Member Variable Result mit dem Default-Konstruierten Wert von ResultType initialisiert.</p>
</blockquote>
<p>vielen dank....habe es einfach mal mit int getestet.</p>
<p>zeile 44:</p>
<blockquote>
<p>struct CommandNM1&lt;void,ArgumentType&gt; : Command</p>
</blockquote>
<p>ist mir auch nicht so ganz klar geworden...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2096097</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2096097</guid><dc:creator><![CDATA[pat.de]]></dc:creator><pubDate>Thu, 21 Jul 2011 13:38:56 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Thu, 21 Jul 2011 14:33:08 GMT]]></title><description><![CDATA[<p>Die Spezialisierung ist notwendig, weil das generische <code>CommandNM1</code> Template eine Membervariable vom Typ <code>ReturnType</code> anlegt (siehe Z. 25). Wenn die aufzurufende Funktion keinen Rückgabewert hat (also void), dann würde <code>ReturnType</code> durch <code>void</code> ersetzt. Der Standard verbietet allerdings Variablen vom Typ <code>void</code> , und das verhindert die Spezialisierung.</p>
<p>Edit:<br />
Zeilennummer korrigiert</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2096118</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2096118</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Thu, 21 Jul 2011 14:33:08 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Fri, 22 Jul 2011 10:26:51 GMT]]></title><description><![CDATA[<p>Vielen Dank nochmal....</p>
<p>Jetzt habe ich das Problem, das ich den operator() mit evtl. rückgabewert und einem parameter aufrufen will.</p>
<pre><code class="language-cpp">Command* c1 = make_command( set_startaddress, &quot;set_startaddress&quot; ); 
(*c1)(400);
</code></pre>
<p>hab dazu erstmal versucht am Code-Abschnitt &quot;Implementation für non-member Funktion mit einem Argument&quot; zu fummeln:</p>
<pre><code class="language-cpp">// Implementation für non-member Funktion mit einem Argument
template&lt;typename ResultType, typename ArgumentType, typename IdType&gt;
struct CommandNM1 : Command&lt;ResultType, ArgumentType&gt;
{
    typedef ResultType( *FuncPtr)( ArgumentType );

    ResultType					Result;
    IdType						Id;
    FuncPtr						Function;

    CommandNM1( FuncPtr Func, IdType _id ) :
        Function( Func ),
        Id( _id ),

    {
    }

	virtual ResultType execute(ArgumentType Arg)
    {

		return Function(Arg);
    }

};
</code></pre>
<p>hab dann anschließend die Basisklasse erweitert:</p>
<pre><code class="language-cpp">// Abstrakte Basisklasse für alle möglichen Commands
template&lt;typename ResultType, typename ArgumentType&gt;
class Command
{
public:
    virtual ~Command()
    {
    }

    virtual ResultType operator()( ArgumentType _Arg)
    {
       return execute(_Arg);
    }

private:
	virtual ResultType execute(ArgumentType Arg) = 0;

};
</code></pre>
<p>und das Funktionstemplate dementsprechend verändert:</p>
<pre><code class="language-cpp">template&lt;typename ResultType, typename ArgumentType, typename IdType&gt;
Command&lt;ResultType, ArgumentType&gt;* make_command( ResultType (*Func)( ArgumentType ), IdType _Id )
{
    return new CommandNM1&lt;ResultType,ArgumentType, IdType&gt;( Func, _Id);
}
</code></pre>
<p>Beim Kompilieren kommt dann folgender Fehler:<br />
<strong>Fehler</strong> 1 error C2955: &quot;Command&quot;: Für die Verwendung der template-Klasse ist eine template-Argumentliste erforderlich.<br />
<strong>Fehler</strong> 2 error C2440: 'Initialisierung': 'Command&lt;ResultType,ArgumentType&gt; *' kann nicht in 'Command *' konvertiert werden<br />
<strong>Fehler</strong> 3 error C3848: Ausdruck mit Typ 'Command' verliert beim Aufrufen von 'ResultType Command&lt;ResultType,ArgumentType&gt;::operator ()(ArgumentType)' möglicherweise einige const-volatile-Qualifizierer</p>
<p>Weiss leider nicht mehr weiter und wäre über eure Hilfe sehr dankbar...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2096425</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2096425</guid><dc:creator><![CDATA[pat.de]]></dc:creator><pubDate>Fri, 22 Jul 2011 10:26:51 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Fri, 22 Jul 2011 10:41:43 GMT]]></title><description><![CDATA[<p><code>Command</code> ist kein Typ, sondern ein Template. Für einen gültigen Typen musst du die Template-Argumente angeben.</p>
<p>Abgesehen davon sind Bezeichner wie <code>_Arg</code> oder <code>_Id</code> , die mit Unterstrich und Grossbuchstaben beginnen, für die Implementierung reserviert. Du solltest sie nicht benutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2096434</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2096434</guid><dc:creator><![CDATA[Nexus]]></dc:creator><pubDate>Fri, 22 Jul 2011 10:41:43 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Fri, 22 Jul 2011 12:36:08 GMT]]></title><description><![CDATA[<p>Die <code>execute()</code> Methode habe ich absichtlich ohne Rückgabewert und Parameter implementiert, dafür ist sie ja virtuell. Wenn du Parameter oder Rückgabewerte brauchst werden die als Member des konkreten Command Typen realisiert. Vereinfacht sieht das dann so aus:</p>
<pre><code class="language-cpp">struct Command
{
   int Result;
   double Argument;
   FuncPtr Func; 

   void execute()
   {
      Result = (*FuncPtr)( Argument );
   }
};

int main()
{
   Command c;

   c.Argument = 101.101;
   c.execute();
   int Ergebnis = c.Result;
}
</code></pre>
<p>Die verschiedenen Ableitungen von Command garantieren, dass ich Command als Basisklasse verwenden darf. Dazu gehört leider auch, dass Command eine Signatur haben muss, über das es alle möglichen Funktionen aufrufen kann, und das ist nun mal <code>void execute()</code> . Die Behandlung von Rückgabewerten oder Aufrufparametern muss irgendwie durch die entsprechenden abgeleiteten Klassen durchgeführt werden, deshalb haben hat <code>CommandNM1</code> die Elemente <code>Result</code> und <code>Argument</code> .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2096495</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2096495</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Fri, 22 Jul 2011 12:36:08 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Mon, 25 Jul 2011 13:27:56 GMT]]></title><description><![CDATA[<p>Ich hab jetzt das Problem,dass ich über den Basisklassenzeiger nicht die Attribute der Objekte aus den abgeleiteten Klassen ändern kann. Wie löse ich das Problem am besten?</p>
<p>Zusätzlich will ich noch Funktionen ohne Rückgabewert und Argumente übergeben, habe dazu den Quelltext wie folg erweitert:</p>
<pre><code class="language-cpp">template&lt;&gt;
struct CommandNM1&lt;void,void&gt; : Command
{
    typedef void( *FuncPtr)( void );

	string					   Id;
    FuncPtr                    Function;

    CommandNM1( FuncPtr Func, string Id_c ) :
		Id(Id_c),
        Function( Func )
    {
    }

    virtual void execute(const int&amp; arg)
    {
        Function(  );
    }

	virtual void execute()
    {
        Function();
    }

	virtual string getId()
    {
        return Id;
    }

};
</code></pre>
<p>und die Funktion <em><em>Command</em> make_command( ResultType (<em>Func)( ArgumentType ), ArgumentType Arg, string Id )</em></em></p>
<p>überladen:</p>
<pre><code class="language-cpp">template&lt;typename ResultType, typename ArgumentType&gt;
Command* make_command( ResultType (*Func)( ArgumentType ), string Id )
{
    return new CommandNM1&lt;ResultType,ArgumentType&gt;( Func, Id );
}
</code></pre>
<p>wenn ich jetzt</p>
<pre><code class="language-cpp">void test(void ){std::cout&lt;&lt;&quot;hallo&quot;; }

int main()
{

	Flash flash52401;
	int t=12;
	flash_init_52401(flash52401);

	Command* c1 = make_command(test ,&quot;hallo&quot;);  ...
</code></pre>
<p>aufrufe sagt der compiler:<br />
Fehler 1 error C2780: 'Command *make_command(ObjectType &amp;,ResultType (__thiscall ObjectType::* )(ArgumentType),ArgumentType,std::string)': Erwartet 4 Argumente - 2 unterstützt<br />
Fehler 4 error C2780: 'Command *make_command(ResultType (__cdecl *)(ArgumentType),ArgumentType,std::string)': Erwartet 3 Argumente - 2 unterstützt<br />
Fehler 2 error C2784: &quot;Command *make_command(ResultType (__cdecl *)(ArgumentType),std::string)&quot;: template-Argument für &quot;überladener Funktionstyp&quot; konnte nicht von &quot;überladener Funktionstyp&quot; hergeleitet werden.<br />
Fehler 3 error C2784: &quot;Command *make_command(ResultType (__cdecl *)(ArgumentType),std::string)&quot;: template-Argument für &quot;überladener Funktionstyp&quot; konnte nicht von &quot;überladener Funktionstyp&quot; hergeleitet werden.</p>
<p><strong>bin am verzweifeln....</strong></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2097616</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2097616</guid><dc:creator><![CDATA[pat.de]]></dc:creator><pubDate>Mon, 25 Jul 2011 13:27:56 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Mon, 25 Jul 2011 14:30:15 GMT]]></title><description><![CDATA[<p>Funktionsaufrufe ohne Argument sind eine neue Template Klasse, die du mit den bisherigen Templates nicht abdecken kannst. Wenn du member und non-member Funktionen damit erschlagen willst brauchst du 4 neue Template Klassen (jeweils 2 für non-member und 2 für member Funktionen, wegen der <code>void</code> Spezialisierung). Wenn du aus denen allerdings auch noch die Rückgabewerte auslesen willst ufert das Ganze extrem aus.<br />
Um das zu vereinfachen könnte man die Basisklasse mit einem Variant Datentyp ausstatten, der den Rückgabewert eines Commands aufnimmt. Damit geht zwar die Typsicherheit flöten, aber man muss keine halsbrecherischen Konstrukte bauen, um an das Ergebnis eines Funktionsaufrufs zu kommen. Du brauchst zwar immer noch 4 templates für jede Kombination einer Funktion (void/non-void und member/non-member), bist damit aber dann auch fertig.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2097650</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2097650</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Mon, 25 Jul 2011 14:30:15 GMT</pubDate></item><item><title><![CDATA[Reply to Problem bei Funktionszeiger! on Tue, 26 Jul 2011 13:24:48 GMT]]></title><description><![CDATA[<p>vielen dank... hab den quellcode jetzt erweitert(für (member-funktion ohne rückgabe und argument) und für( non member ohne rückgabe und ohne argument) ).</p>
<p>Jetzt habe ich folgendes Problem: Ich habe auch Funktionen mit Verweise bspw.</p>
<pre><code class="language-cpp">void set_startaddress(const int &amp;addr)
</code></pre>
<p>...muss ich dafür auch wieder extra eine template-kalsse erstellen??</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2097975</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2097975</guid><dc:creator><![CDATA[pat.de]]></dc:creator><pubDate>Tue, 26 Jul 2011 13:24:48 GMT</pubDate></item></channel></rss>