<?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[Process-Klasse mit ths als Übergabeparameter]]></title><description><![CDATA[<p>Hallo c++-community,</p>
<p>ich versuche gerade zu Übungszwecken eine Prozess-Klasse zu erstellen. Dabei soll this der Übergabeparameter sein und eine Methode der Klasse die ausgeführte Funktion. Der Aufbau ist so:</p>
<p>process.h</p>
<pre><code>class clProcess
    {
        public:
            // constructor and destructor
            clProcess (void);
            virtual         ~clProcess (void);

            // methodes
            virtual void*   MainLoop(void* Argv);

        private:
            pthread_t       _thread;
    };
</code></pre>
<p>process.cpp</p>
<pre><code>#include    &quot;process.h&quot;

clProcess::clProcess(void){
    // funktioniert noch nicht
    pthread_create(&amp;this-&gt;_thread, NULL, this-&gt;MainLoop, (void*)this);
}

clProcess::~clProcess(void){
    if (this-&gt;_thread != 0){
        pthread_join(this-&gt;_thread, NULL);
    }
}

void* clProcess::MainLoop(void*){
    // tu etwas
    return NULL;
}
</code></pre>
<p>derzeit beokomme ich noch folgende Fehlermeldung:</p>
<blockquote>
<p>invalid use of non-static member function<br />
pthread_create(&amp;this-&gt;_thread, NULL, this-&gt;MainLoop, (void*)this);</p>
</blockquote>
<p>Die Frage ist jetzt natürlich, ob die Übergabe von this überhaupt nötig ist? Problem scheint aber die Übergabe der Methode MainLoop.</p>
<p>mirrowwinger</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/337060/process-klasse-mit-ths-als-übergabeparameter</link><generator>RSS for Node</generator><lastBuildDate>Sat, 18 Apr 2026 11:52:19 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/337060.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 05 Mar 2016 11:50:09 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Process-Klasse mit ths als Übergabeparameter on Sat, 05 Mar 2016 11:50:09 GMT]]></title><description><![CDATA[<p>Hallo c++-community,</p>
<p>ich versuche gerade zu Übungszwecken eine Prozess-Klasse zu erstellen. Dabei soll this der Übergabeparameter sein und eine Methode der Klasse die ausgeführte Funktion. Der Aufbau ist so:</p>
<p>process.h</p>
<pre><code>class clProcess
    {
        public:
            // constructor and destructor
            clProcess (void);
            virtual         ~clProcess (void);

            // methodes
            virtual void*   MainLoop(void* Argv);

        private:
            pthread_t       _thread;
    };
</code></pre>
<p>process.cpp</p>
<pre><code>#include    &quot;process.h&quot;

clProcess::clProcess(void){
    // funktioniert noch nicht
    pthread_create(&amp;this-&gt;_thread, NULL, this-&gt;MainLoop, (void*)this);
}

clProcess::~clProcess(void){
    if (this-&gt;_thread != 0){
        pthread_join(this-&gt;_thread, NULL);
    }
}

void* clProcess::MainLoop(void*){
    // tu etwas
    return NULL;
}
</code></pre>
<p>derzeit beokomme ich noch folgende Fehlermeldung:</p>
<blockquote>
<p>invalid use of non-static member function<br />
pthread_create(&amp;this-&gt;_thread, NULL, this-&gt;MainLoop, (void*)this);</p>
</blockquote>
<p>Die Frage ist jetzt natürlich, ob die Übergabe von this überhaupt nötig ist? Problem scheint aber die Übergabe der Methode MainLoop.</p>
<p>mirrowwinger</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2489385</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2489385</guid><dc:creator><![CDATA[mirrowwinger]]></dc:creator><pubDate>Sat, 05 Mar 2016 11:50:09 GMT</pubDate></item><item><title><![CDATA[Reply to Process-Klasse mit ths als Übergabeparameter on Sat, 05 Mar 2016 12:00:48 GMT]]></title><description><![CDATA[<p>Warum ist MainLoop eine Memberfunktion?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2489388</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2489388</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Sat, 05 Mar 2016 12:00:48 GMT</pubDate></item><item><title><![CDATA[Reply to Process-Klasse mit ths als Übergabeparameter on Sat, 05 Mar 2016 13:06:39 GMT]]></title><description><![CDATA[<p>Üblicherweise gibt es eine statische 'sprungbrett'-funktion, welche eben asynchron gestartet wird. Die kann zb den void* wieder in eine this* casten und dann eine std::function aufrufen, welche letztendlich auf die benutzerfunktion zeigt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2489394</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2489394</guid><dc:creator><![CDATA[Techel]]></dc:creator><pubDate>Sat, 05 Mar 2016 13:06:39 GMT</pubDate></item><item><title><![CDATA[Reply to Process-Klasse mit ths als Übergabeparameter on Sat, 05 Mar 2016 13:09:12 GMT]]></title><description><![CDATA[<p>Ok hab jetzt MainLoop nicht mehr als Memberfunktion:</p>
<p>process.h</p>
<pre><code>class clProcess
    {
        public:
            // constructor and destructor
            clProcess (void);
            virtual         ~clProcess (void);

        private:
            pthread_t       _thread;
    };

void* MainLoop(void* Argv);
</code></pre>
<p>process.cpp</p>
<pre><code>#include    &quot;process.h&quot;

clProcess::clProcess(void){
    // funktioniert
    pthread_create(&amp;this-&gt;_thread, NULL, MainLoop, (void*)this);
}

clProcess::~clProcess(void){
    if (this-&gt;_thread != 0){
        pthread_join(this-&gt;_thread, NULL);
    }
}

void* MainLoop(void*){
    // funktioniert noch nicht
    clProcess _process  =   (clProcess) Argv;
    return NULL;
}
</code></pre>
<p>Allerdings funktioniert das zurück Casten noch nicht. (Ich gebe zu ich habe es mit meinen c-Kenntnissen probiert.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2489395</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2489395</guid><dc:creator><![CDATA[mirrowwinger]]></dc:creator><pubDate>Sat, 05 Mar 2016 13:09:12 GMT</pubDate></item><item><title><![CDATA[Reply to Process-Klasse mit ths als Übergabeparameter on Sat, 05 Mar 2016 13:22:03 GMT]]></title><description><![CDATA[<p>Funktioniert nicht - was für eine präzise Aussage. Auch C-Compiler geben schon Fehlermeldungen aus, sollte also nichts unbekanntes für dich sein.</p>
<p>Und auch in C wird aus einem Structpointer durch Casten nicht plötzlich eine Struct.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2489396</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2489396</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Sat, 05 Mar 2016 13:22:03 GMT</pubDate></item></channel></rss>