<?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[Probleme mit abgeleiteter Klasse]]></title><description><![CDATA[<p>Hallo zusammen!</p>
<p>Der GCC-Compiler beschwert sich über Zeile 21 in der IRCBot.cpp.<br />
Fehlermeldung:</p>
<pre><code>../IRC/IRCBot.cpp: In member function ‘int IRCBot::connectIRC()’:
../IRC/IRCBot.cpp:28: error: no matching function for call to ‘IRCBot::hook_irc_command(const char [13], int (IRCBot::*)(char*, irc_reply_data*, void*))’
../IRC/IRC.h:79: note: candidates are: void IRC::hook_irc_command(char*, int (*)(char*, irc_reply_data*, void*))
make: *** [IRC/IRCBot.o] Error 1
</code></pre>
<p>Hat jemand vielleicht eine Idee, wie man das hinbekommen könnte?</p>
<p>IRCBot.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;stdio.h&gt;
#include &lt;pthread.h&gt;
#include &lt;unistd.h&gt;
#include &quot;IRCBot.h&quot;

using namespace std;

IRCBot::IRCBot() : IRC()
{

	//Konstruktor

}

int IRCBot::connectIRC()
{

	IRCBot conn;

	conn.hook_irc_command(&quot;irc response&quot;, &amp;IRCBot::IRCCommandHandler); 

	conn.start(&quot;irc.efnet.ch&quot;,6667,&quot;test&quot;,&quot;test&quot;,&quot;test&quot;,&quot;password&quot;);

	conn.join(&quot;#test&quot;);

	conn.message_loop();

	return 0;
}

int IRCBot::IRCCommandHandler(char* params, irc_reply_data* hostd, void* conn)
{
	IRCBot* irc_conn=(IRCBot*)conn; /* notice that you are passed a pointer to the connection object */

	irc_conn-&gt;disconnect();

	return 0;
}
</code></pre>
<p>IRCBot.h</p>
<pre><code class="language-cpp">#ifndef IRCBOT_H_
#define IRCBOT_H_

#include &quot;IRC.h&quot;

class IRCBot : public IRC {
	public:
		IRCBot();
		int connectIRC();
		int IRCCommandHandler(char*, irc_reply_data*, void*);
		int end_of_motd(char* params, irc_reply_data* hostd, void* conn);
	private:	
};

#endif /*IRCBOT_H_*/
</code></pre>
<p>IRC.cpp</p>
<pre><code class="language-cpp">[...]
void IRC::hook_irc_command(char* cmd_name, int (*function_ptr)(char*, irc_reply_data*, void*))
{
	if (!hooks)
	{
		hooks=new irc_command_hook;
		hooks-&gt;function=0;
		hooks-&gt;irc_command=0;
		hooks-&gt;next=0;
		insert_irc_command_hook(hooks, cmd_name, function_ptr);
	}
	else
	{
		insert_irc_command_hook(hooks, cmd_name, function_ptr);
	}
}
[...]
</code></pre>
<p>IRC.h</p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;
#include &lt;stdarg.h&gt;

#define __CPIRC_VERSION__	0.1
#define __IRC_DEBUG__ 1

#define IRC_USER_VOICE	1
#define IRC_USER_HALFOP	2
#define IRC_USER_OP		4

struct irc_reply_data
{
	char* nick;
	char* ident;
	char* host;
	char* target;
};

struct irc_command_hook
{
	char* irc_command;
	int (*function)(char*, irc_reply_data*, void*);
	irc_command_hook* next;
};

struct channel_user
{
	char* nick;
	char* channel;
	char flags;
	channel_user* next;
};

class IRC
{
public:
	IRC();
	~IRC();
	int start(char* server, int port, char* nick, char* user, char* name, char* pass);
	void disconnect();
	int privmsg(char* target, char* message);
	int privmsg(char* fmt, ...);
	int notice(char* target, char* message);
	int notice(char* fmt, ...);
	int join(char* channel);
	int part(char* channel);
	int kick(char* channel, char* nick);
	int kick(char* channel, char* nick, char* message);
	int mode(char* modes);
	int mode(char* channel, char* modes, char* targets);
	int nick(char* newnick);
	int quit(char* quit_message);
	int raw(char* data);
	void hook_irc_command(char* cmd_name, int (*function_ptr)(char*, irc_reply_data*, void*));
	int message_loop();
	int is_op(char* channel, char* nick);
	int is_voice(char* channel, char* nick);
	char* current_nick();
private:
	void call_hook(char* irc_command, char*params, irc_reply_data* hostd);
	/*void call_the_hook(irc_command_hook* hook, char* irc_command, char*params, irc_host_data* hostd);*/
	void parse_irc_reply(char* data);
	void split_to_replies(char* data);
	void insert_irc_command_hook(irc_command_hook* hook, char* cmd_name, int (*function_ptr)(char*, irc_reply_data*, void*));
	void delete_irc_command_hook(irc_command_hook* cmd_hook);
	int irc_socket;
	bool connected;
	bool sentnick;
	bool sentpass;
	bool sentuser;
	char* cur_nick;
	FILE* dataout;
	FILE* datain;
	channel_user* chan_users;
	irc_command_hook* hooks;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/182428/probleme-mit-abgeleiteter-klasse</link><generator>RSS for Node</generator><lastBuildDate>Tue, 22 Sep 2026 21:11:23 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/182428.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 24 May 2007 21:28:48 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme mit abgeleiteter Klasse on Thu, 24 May 2007 21:41:29 GMT]]></title><description><![CDATA[<p>Hallo zusammen!</p>
<p>Der GCC-Compiler beschwert sich über Zeile 21 in der IRCBot.cpp.<br />
Fehlermeldung:</p>
<pre><code>../IRC/IRCBot.cpp: In member function ‘int IRCBot::connectIRC()’:
../IRC/IRCBot.cpp:28: error: no matching function for call to ‘IRCBot::hook_irc_command(const char [13], int (IRCBot::*)(char*, irc_reply_data*, void*))’
../IRC/IRC.h:79: note: candidates are: void IRC::hook_irc_command(char*, int (*)(char*, irc_reply_data*, void*))
make: *** [IRC/IRCBot.o] Error 1
</code></pre>
<p>Hat jemand vielleicht eine Idee, wie man das hinbekommen könnte?</p>
<p>IRCBot.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;stdio.h&gt;
#include &lt;pthread.h&gt;
#include &lt;unistd.h&gt;
#include &quot;IRCBot.h&quot;

using namespace std;

IRCBot::IRCBot() : IRC()
{

	//Konstruktor

}

int IRCBot::connectIRC()
{

	IRCBot conn;

	conn.hook_irc_command(&quot;irc response&quot;, &amp;IRCBot::IRCCommandHandler); 

	conn.start(&quot;irc.efnet.ch&quot;,6667,&quot;test&quot;,&quot;test&quot;,&quot;test&quot;,&quot;password&quot;);

	conn.join(&quot;#test&quot;);

	conn.message_loop();

	return 0;
}

int IRCBot::IRCCommandHandler(char* params, irc_reply_data* hostd, void* conn)
{
	IRCBot* irc_conn=(IRCBot*)conn; /* notice that you are passed a pointer to the connection object */

	irc_conn-&gt;disconnect();

	return 0;
}
</code></pre>
<p>IRCBot.h</p>
<pre><code class="language-cpp">#ifndef IRCBOT_H_
#define IRCBOT_H_

#include &quot;IRC.h&quot;

class IRCBot : public IRC {
	public:
		IRCBot();
		int connectIRC();
		int IRCCommandHandler(char*, irc_reply_data*, void*);
		int end_of_motd(char* params, irc_reply_data* hostd, void* conn);
	private:	
};

#endif /*IRCBOT_H_*/
</code></pre>
<p>IRC.cpp</p>
<pre><code class="language-cpp">[...]
void IRC::hook_irc_command(char* cmd_name, int (*function_ptr)(char*, irc_reply_data*, void*))
{
	if (!hooks)
	{
		hooks=new irc_command_hook;
		hooks-&gt;function=0;
		hooks-&gt;irc_command=0;
		hooks-&gt;next=0;
		insert_irc_command_hook(hooks, cmd_name, function_ptr);
	}
	else
	{
		insert_irc_command_hook(hooks, cmd_name, function_ptr);
	}
}
[...]
</code></pre>
<p>IRC.h</p>
<pre><code class="language-cpp">#include &lt;stdio.h&gt;
#include &lt;stdarg.h&gt;

#define __CPIRC_VERSION__	0.1
#define __IRC_DEBUG__ 1

#define IRC_USER_VOICE	1
#define IRC_USER_HALFOP	2
#define IRC_USER_OP		4

struct irc_reply_data
{
	char* nick;
	char* ident;
	char* host;
	char* target;
};

struct irc_command_hook
{
	char* irc_command;
	int (*function)(char*, irc_reply_data*, void*);
	irc_command_hook* next;
};

struct channel_user
{
	char* nick;
	char* channel;
	char flags;
	channel_user* next;
};

class IRC
{
public:
	IRC();
	~IRC();
	int start(char* server, int port, char* nick, char* user, char* name, char* pass);
	void disconnect();
	int privmsg(char* target, char* message);
	int privmsg(char* fmt, ...);
	int notice(char* target, char* message);
	int notice(char* fmt, ...);
	int join(char* channel);
	int part(char* channel);
	int kick(char* channel, char* nick);
	int kick(char* channel, char* nick, char* message);
	int mode(char* modes);
	int mode(char* channel, char* modes, char* targets);
	int nick(char* newnick);
	int quit(char* quit_message);
	int raw(char* data);
	void hook_irc_command(char* cmd_name, int (*function_ptr)(char*, irc_reply_data*, void*));
	int message_loop();
	int is_op(char* channel, char* nick);
	int is_voice(char* channel, char* nick);
	char* current_nick();
private:
	void call_hook(char* irc_command, char*params, irc_reply_data* hostd);
	/*void call_the_hook(irc_command_hook* hook, char* irc_command, char*params, irc_host_data* hostd);*/
	void parse_irc_reply(char* data);
	void split_to_replies(char* data);
	void insert_irc_command_hook(irc_command_hook* hook, char* cmd_name, int (*function_ptr)(char*, irc_reply_data*, void*));
	void delete_irc_command_hook(irc_command_hook* cmd_hook);
	int irc_socket;
	bool connected;
	bool sentnick;
	bool sentpass;
	bool sentuser;
	char* cur_nick;
	FILE* dataout;
	FILE* datain;
	channel_user* chan_users;
	irc_command_hook* hooks;
};
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1291835</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291835</guid><dc:creator><![CDATA[cheebido]]></dc:creator><pubDate>Thu, 24 May 2007 21:41:29 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit abgeleiteter Klasse on Thu, 24 May 2007 21:41:45 GMT]]></title><description><![CDATA[<p>du brauchst boost::function und boost::bind aus der boost library</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291842</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291842</guid><dc:creator><![CDATA[wie]]></dc:creator><pubDate>Thu, 24 May 2007 21:41:45 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit abgeleiteter Klasse on Fri, 25 May 2007 06:42:49 GMT]]></title><description><![CDATA[<p>Wenn die Funktionen nicht die Absicht haben, die übergebenen Strings zu ändern, sollten sie das auch dazusagen und einen 'const char*' (oder noch besser 'const string&amp;' entgegennehmen.</p>
<p>Außerdem kannst du an einen normalen Funktionszeiger keine Klassenmethode übergeben (das scheitert an einem fehlenden this-Zeiger), sondern nur globale Funktionen oder statische Methoden.</p>
<p>PS: Wieso legst du in der IRCBot::connectIRC() eigentlich ein neues Objekt an? Du hast doch schon eins (namens *this). Und dein Objekt 'conn' wird am Ende der Methode wieder gelöscht und vergisst die ganzen Callback-Funktionen wieder.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1291935</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1291935</guid><dc:creator><![CDATA[CStoll]]></dc:creator><pubDate>Fri, 25 May 2007 06:42:49 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit abgeleiteter Klasse on Fri, 25 May 2007 12:23:15 GMT]]></title><description><![CDATA[<p>Sorry, das war noch etwas ungeschickt. Sind halt erst dabei, uns in die neue Sprache einzuarbeiten.<br />
Das Ganze wurde jetzt nochmal umgeschrieben, so dass der Code etwas durchsichtiger und besser strukturiert ist. Jetzt klappt es auch - erstmal. <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>Danke für die Antworten! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1292196</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1292196</guid><dc:creator><![CDATA[cheebido]]></dc:creator><pubDate>Fri, 25 May 2007 12:23:15 GMT</pubDate></item></channel></rss>