<?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[Frage zu Klasse]]></title><description><![CDATA[<p>Hallo ich habe mir dieses Programm geschrieben es funktioniert auch.</p>
<p>Jedoch bekomme ich immer diese Linker Warnung mit ausgeben:</p>
<p>[ILINK32 Warnung] Warning: Public Symbol '_pixel' ist in Modul C:\USERS\DR\DESKTOP\RUPT BOT\DEBUG\FILE1.OBJ und C:\USERS\us\DESKTOP\prog\DEBUG\PIXEL_COLOR.OBJ definiert</p>
<p>Irgendwie kann ich mit der Warnung nichts anfangen ...</p>
<p>Ok ich könnte jetzt sagen die Warnung is mir egal das Programm funktioniert ja. ^^</p>
<p>Aber ich würde trotzdem gerne wissen was die bedeutet.</p>
<p>main.cpp</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;iostream.h&gt;
#include &lt;fstream.h&gt;
#include &lt;conio.h&gt;

#include &quot;pixel_color.h&quot;

using namespace std;

int main(int argc, char* argv[])
{

int ret=0;

ret = pixel.get_pixel_color(20,20);

cout&lt;&lt;ret&lt;&lt;endl;

return 0;
}
</code></pre>
<p>pixel_color.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream.h&gt;
#include &lt;windows.h&gt;
#include &quot;pixel_color.h&quot;
using namespace std;

COLORREF pixel_class :: get_pixel_color ( int x , int y)
{
COLORREF farbe;
HDC desktop;

desktop = GetDC(0) ;

farbe = GetPixel ( desktop ,  x , y );

}

return farbe;
}
</code></pre>
<p>pixel_color.h</p>
<pre><code class="language-cpp">#ifndef PIXEL_CLASS_H
#define PIXEL_CLASS_H

class pixel_class
{

public:

COLORREF get_pixel_color ( int x , int y );

};

pixel_class pixel;

#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/277373/frage-zu-klasse</link><generator>RSS for Node</generator><lastBuildDate>Tue, 25 Aug 2026 22:47:20 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/277373.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 17 Nov 2010 16:47:05 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Frage zu Klasse on Wed, 17 Nov 2010 16:47:05 GMT]]></title><description><![CDATA[<p>Hallo ich habe mir dieses Programm geschrieben es funktioniert auch.</p>
<p>Jedoch bekomme ich immer diese Linker Warnung mit ausgeben:</p>
<p>[ILINK32 Warnung] Warning: Public Symbol '_pixel' ist in Modul C:\USERS\DR\DESKTOP\RUPT BOT\DEBUG\FILE1.OBJ und C:\USERS\us\DESKTOP\prog\DEBUG\PIXEL_COLOR.OBJ definiert</p>
<p>Irgendwie kann ich mit der Warnung nichts anfangen ...</p>
<p>Ok ich könnte jetzt sagen die Warnung is mir egal das Programm funktioniert ja. ^^</p>
<p>Aber ich würde trotzdem gerne wissen was die bedeutet.</p>
<p>main.cpp</p>
<pre><code class="language-cpp">#include &lt;windows.h&gt;
#include &lt;iostream.h&gt;
#include &lt;fstream.h&gt;
#include &lt;conio.h&gt;

#include &quot;pixel_color.h&quot;

using namespace std;

int main(int argc, char* argv[])
{

int ret=0;

ret = pixel.get_pixel_color(20,20);

cout&lt;&lt;ret&lt;&lt;endl;

return 0;
}
</code></pre>
<p>pixel_color.cpp</p>
<pre><code class="language-cpp">#include &lt;iostream.h&gt;
#include &lt;windows.h&gt;
#include &quot;pixel_color.h&quot;
using namespace std;

COLORREF pixel_class :: get_pixel_color ( int x , int y)
{
COLORREF farbe;
HDC desktop;

desktop = GetDC(0) ;

farbe = GetPixel ( desktop ,  x , y );

}

return farbe;
}
</code></pre>
<p>pixel_color.h</p>
<pre><code class="language-cpp">#ifndef PIXEL_CLASS_H
#define PIXEL_CLASS_H

class pixel_class
{

public:

COLORREF get_pixel_color ( int x , int y );

};

pixel_class pixel;

#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1981824</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1981824</guid><dc:creator><![CDATA[_Class]]></dc:creator><pubDate>Wed, 17 Nov 2010 16:47:05 GMT</pubDate></item><item><title><![CDATA[Reply to Frage zu Klasse on Wed, 17 Nov 2010 16:57:49 GMT]]></title><description><![CDATA[<p>pixel_color.h:</p>
<pre><code class="language-cpp">#ifndef PIXEL_CLASS_H
#define PIXEL_CLASS_H
class pixel_class {
public:
  COLORREF get_pixel_color ( int x , int y );
};

// hier extern hinzufügen
extern pixel_class pixel;

#endif
</code></pre>
<p>pixel_color.cpp:</p>
<pre><code class="language-cpp">...
pixel_class pixel; // diese Zeile hinzufügen
...
</code></pre>
<p>Das Problem ist, dass jedesmal, wenn der Header eingebunden wird, die Variable pixel erneut definiert wird und damit pro Datei auf eine andere Instanz zugegriffen wird. extern verhindert das und sagt bloss, dass so eine Instanz existiert und nicht neu erstellt werden muss.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1981831</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1981831</guid><dc:creator><![CDATA[ternex]]></dc:creator><pubDate>Wed, 17 Nov 2010 16:57:49 GMT</pubDate></item></channel></rss>