<?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[mehrfach definiertes Symbol gefunden]]></title><description><![CDATA[<p>ich hab von einer klasse eine abgeleitete klasse erstellt, die hat ganz normal ihre funktionen und elemente. dann hab ich noch eine header datei namens Global.h, da sind einfach globale funktionen drin wie die breite eines RECT zu kriegen.<br />
seit ich die abgeleitete klasse jetzt erstellt hab, kommt für alle funktionen in Global.h der error LNK2005, zum beispiel</p>
<pre><code>1&gt;WinWrap.obj : error LNK2005: &quot;bool __cdecl std::outOfBounds(int,int,int,int,struct tagRECT)&quot; (?outOfBounds@std@@YA_NHHHHUtagRECT@@@Z) ist bereits in ScrollBar.obj definiert.
</code></pre>
<p>erstmal weis ich nichtmal aus welcher datei ScrollBar.obj erstellt wurde, aber nirgendwo hab ich 2 mal dieselbe funktion definiert. auch nicht in der klasse. ich hab funktionen mit demselben namen, aber die nehmen andere argumente, also muss es gehen.</p>
<p>hier ist Global.h:</p>
<pre><code>#ifndef _GLOBAL_H_
#define _GLOBAL_H_
#include &quot;Cout.h&quot;

extern Cout cout;

	int getWidth(RECT* r)
	{return r-&gt;right-r-&gt;left;}

	int getHeight(RECT* r)
	{return r-&gt;bottom-r-&gt;top;}

	bool outOfBounds(RECT r, RECT area)
	{
	  return(r.right&gt;area.right || r.left&lt;area.left || r.top&lt;area.top || r.bottom&gt;area.bottom);
	}

	void print(Cout&amp; cout, RECT* r)
	{
		cout&lt;&lt;r-&gt;left&lt;&lt;&quot; / &quot;&lt;&lt;r-&gt;top&lt;&lt;&quot; / &quot;&lt;&lt;r-&gt;right&lt;&lt;&quot; / &quot;&lt;&lt;r-&gt;bottom&lt;&lt;&quot;\n&quot;;
	}

	bool outOfBounds(int x, int y, int w, int h, RECT area)
	{
		RECT r;
		r.left=x; r.top=y; r.right=x+w; r.bottom=y+h;
		return outOfBounds(r,area);
	}

#endif
</code></pre>
<p>und hier WinWrap.h:</p>
<pre><code>#ifndef _WINWRAPPER_H_
#define _WINWRAPPER_H_

#include &lt;Windows.h&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &quot;Cout.h&quot;
#include &quot;resource.h&quot;

class WinWrap

{
public:

  vector&lt;WinWrap*&gt;children;

  WinWrap* pParent;

  unsigned short usPosFlags;

  HWND hWnd;

  DWORD dwExStyle;
  LPCTSTR lpClassName;
  LPCTSTR lpWindowName;
  DWORD dwStyle;

  int i_margin_left;
  int i_margin_top;
  int i_margin_right;
  int i_margin_bottom;

  int x;
  int y;

  int nWidth;
  int nHeight;
  HWND hWndParent;
  HMENU hMenu;
  HINSTANCE hInstance;
  LPVOID lpParam;

  WinWrap(LPCTSTR lpClassName,
	  LPCTSTR lpWindowName,
	  DWORD dwStyle,
	  int x,
	  int y,
	  int nWidth,
	  int nHeight,
	  HWND hWndParent=NULL,
	  HMENU hMenu=NULL,
	  HINSTANCE hInstance=NULL,
	  LPVOID lpParam=NULL,
	  unsigned short usPosFlags=X_ALIGN_LEFT | Y_ALIGN_TOP
	  );

  WinWrap();

  void init(
	  LPCTSTR lpClassName,
	  LPCTSTR lpWindowName,
	  DWORD dwStyle,
	  int x,
	  int y,
	  int nWidth,
	  int nHeight,
	  HWND hWndParent=NULL,
	  HMENU hMenu=NULL,
	  HINSTANCE hInstance=NULL,
	  LPVOID lpParam=NULL,
	  unsigned short usPosFlags=X_ALIGN_LEFT | Y_ALIGN_TOP  
	  );

  int update();

  int updateChildrenPos();

  RECT getWindowRect();

  RECT getClientRect(){RECT r; GetClientRect(hWnd, &amp;r); return r;}

  //variablen im winwrap objekt aktualisieren
  void updateVars();

  BOOL createWindow();

  int getX(){return x;}
  int getY(){return y;}

  int getWidth(){return nWidth;}
  int getHeight(){return nHeight;}

  int calculateX(WinWrap* before=NULL);
  int calculateY(WinWrap* before=NULL);

  int calculateWidth();
  int calculateHeight();

  bool addChild(WinWrap* pChild, bool create=1);

  void create(){	if(createWindow())
		ShowWindow(hWnd,1);	}

  int childCount() {return children.size();}
  WinWrap* childAt(int i) {return children.at(i);}

  void show(){ShowWindow(hWnd, 1);}
  void hide(){ShowWindow(hWnd,0);}

  BOOL setWindowPos(int x, int y){return SetWindowPos(hWnd, 0, x,y,0,0,SWP_NOSIZE);}

  BOOL setWindowSize(int x, int y){return SetWindowPos(hWnd, 0, 0,0,x,y,SWP_NOMOVE);}

  RECT getRect(){RECT r; r.left=getX(); r.top=getY(); r.bottom=r.top+getHeight(); r.right=r.left+getWidth(); return r;}

};

class ScrollBar:public WinWrap
{

public:
	int scrollRange;
	int scrollPos;
	int scrollStep;

	int max_w;
	int max_h;

	ScrollBar(
	  DWORD dwType,
	  int x,
	  int y,
	  int nWidth,
	  int nHeight,
	  HWND parent,
	  HMENU hMenu=NULL,
	  unsigned short usPosFlags=X_ALIGN_LEFT | Y_ALIGN_TOP
	  );

	LRESULT defaultProc(DWORD wParam);

	void setScrollRange(int n) {scrollRange=n; SetScrollRange(hWnd,SB_CTL,0,n,true);}
	void setScrollPos(int n);
	void setScrollStep(int n){this-&gt;scrollStep=n;}

	int getScrollRange ()const{return scrollRange;}
	int getScrollPos() const {return scrollPos;}
	int getScrollStep() const {scrollStep;}

};

#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/311383/mehrfach-definiertes-symbol-gefunden</link><generator>RSS for Node</generator><lastBuildDate>Mon, 03 Aug 2026 16:43:09 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/311383.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 04 Dec 2012 10:24:44 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to mehrfach definiertes Symbol gefunden on Tue, 04 Dec 2012 10:24:44 GMT]]></title><description><![CDATA[<p>ich hab von einer klasse eine abgeleitete klasse erstellt, die hat ganz normal ihre funktionen und elemente. dann hab ich noch eine header datei namens Global.h, da sind einfach globale funktionen drin wie die breite eines RECT zu kriegen.<br />
seit ich die abgeleitete klasse jetzt erstellt hab, kommt für alle funktionen in Global.h der error LNK2005, zum beispiel</p>
<pre><code>1&gt;WinWrap.obj : error LNK2005: &quot;bool __cdecl std::outOfBounds(int,int,int,int,struct tagRECT)&quot; (?outOfBounds@std@@YA_NHHHHUtagRECT@@@Z) ist bereits in ScrollBar.obj definiert.
</code></pre>
<p>erstmal weis ich nichtmal aus welcher datei ScrollBar.obj erstellt wurde, aber nirgendwo hab ich 2 mal dieselbe funktion definiert. auch nicht in der klasse. ich hab funktionen mit demselben namen, aber die nehmen andere argumente, also muss es gehen.</p>
<p>hier ist Global.h:</p>
<pre><code>#ifndef _GLOBAL_H_
#define _GLOBAL_H_
#include &quot;Cout.h&quot;

extern Cout cout;

	int getWidth(RECT* r)
	{return r-&gt;right-r-&gt;left;}

	int getHeight(RECT* r)
	{return r-&gt;bottom-r-&gt;top;}

	bool outOfBounds(RECT r, RECT area)
	{
	  return(r.right&gt;area.right || r.left&lt;area.left || r.top&lt;area.top || r.bottom&gt;area.bottom);
	}

	void print(Cout&amp; cout, RECT* r)
	{
		cout&lt;&lt;r-&gt;left&lt;&lt;&quot; / &quot;&lt;&lt;r-&gt;top&lt;&lt;&quot; / &quot;&lt;&lt;r-&gt;right&lt;&lt;&quot; / &quot;&lt;&lt;r-&gt;bottom&lt;&lt;&quot;\n&quot;;
	}

	bool outOfBounds(int x, int y, int w, int h, RECT area)
	{
		RECT r;
		r.left=x; r.top=y; r.right=x+w; r.bottom=y+h;
		return outOfBounds(r,area);
	}

#endif
</code></pre>
<p>und hier WinWrap.h:</p>
<pre><code>#ifndef _WINWRAPPER_H_
#define _WINWRAPPER_H_

#include &lt;Windows.h&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
#include &quot;Cout.h&quot;
#include &quot;resource.h&quot;

class WinWrap

{
public:

  vector&lt;WinWrap*&gt;children;

  WinWrap* pParent;

  unsigned short usPosFlags;

  HWND hWnd;

  DWORD dwExStyle;
  LPCTSTR lpClassName;
  LPCTSTR lpWindowName;
  DWORD dwStyle;

  int i_margin_left;
  int i_margin_top;
  int i_margin_right;
  int i_margin_bottom;

  int x;
  int y;

  int nWidth;
  int nHeight;
  HWND hWndParent;
  HMENU hMenu;
  HINSTANCE hInstance;
  LPVOID lpParam;

  WinWrap(LPCTSTR lpClassName,
	  LPCTSTR lpWindowName,
	  DWORD dwStyle,
	  int x,
	  int y,
	  int nWidth,
	  int nHeight,
	  HWND hWndParent=NULL,
	  HMENU hMenu=NULL,
	  HINSTANCE hInstance=NULL,
	  LPVOID lpParam=NULL,
	  unsigned short usPosFlags=X_ALIGN_LEFT | Y_ALIGN_TOP
	  );

  WinWrap();

  void init(
	  LPCTSTR lpClassName,
	  LPCTSTR lpWindowName,
	  DWORD dwStyle,
	  int x,
	  int y,
	  int nWidth,
	  int nHeight,
	  HWND hWndParent=NULL,
	  HMENU hMenu=NULL,
	  HINSTANCE hInstance=NULL,
	  LPVOID lpParam=NULL,
	  unsigned short usPosFlags=X_ALIGN_LEFT | Y_ALIGN_TOP  
	  );

  int update();

  int updateChildrenPos();

  RECT getWindowRect();

  RECT getClientRect(){RECT r; GetClientRect(hWnd, &amp;r); return r;}

  //variablen im winwrap objekt aktualisieren
  void updateVars();

  BOOL createWindow();

  int getX(){return x;}
  int getY(){return y;}

  int getWidth(){return nWidth;}
  int getHeight(){return nHeight;}

  int calculateX(WinWrap* before=NULL);
  int calculateY(WinWrap* before=NULL);

  int calculateWidth();
  int calculateHeight();

  bool addChild(WinWrap* pChild, bool create=1);

  void create(){	if(createWindow())
		ShowWindow(hWnd,1);	}

  int childCount() {return children.size();}
  WinWrap* childAt(int i) {return children.at(i);}

  void show(){ShowWindow(hWnd, 1);}
  void hide(){ShowWindow(hWnd,0);}

  BOOL setWindowPos(int x, int y){return SetWindowPos(hWnd, 0, x,y,0,0,SWP_NOSIZE);}

  BOOL setWindowSize(int x, int y){return SetWindowPos(hWnd, 0, 0,0,x,y,SWP_NOMOVE);}

  RECT getRect(){RECT r; r.left=getX(); r.top=getY(); r.bottom=r.top+getHeight(); r.right=r.left+getWidth(); return r;}

};

class ScrollBar:public WinWrap
{

public:
	int scrollRange;
	int scrollPos;
	int scrollStep;

	int max_w;
	int max_h;

	ScrollBar(
	  DWORD dwType,
	  int x,
	  int y,
	  int nWidth,
	  int nHeight,
	  HWND parent,
	  HMENU hMenu=NULL,
	  unsigned short usPosFlags=X_ALIGN_LEFT | Y_ALIGN_TOP
	  );

	LRESULT defaultProc(DWORD wParam);

	void setScrollRange(int n) {scrollRange=n; SetScrollRange(hWnd,SB_CTL,0,n,true);}
	void setScrollPos(int n);
	void setScrollStep(int n){this-&gt;scrollStep=n;}

	int getScrollRange ()const{return scrollRange;}
	int getScrollPos() const {return scrollPos;}
	int getScrollStep() const {scrollStep;}

};

#endif
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2277037</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2277037</guid><dc:creator><![CDATA[Francis123]]></dc:creator><pubDate>Tue, 04 Dec 2012 10:24:44 GMT</pubDate></item><item><title><![CDATA[Reply to mehrfach definiertes Symbol gefunden on Tue, 04 Dec 2012 10:42:16 GMT]]></title><description><![CDATA[<p>In einen Header kommen keine Definitionen (außer inline oder Templates), denn sonst sind diese Definitionen hinterher in jeder Übersetzungseinheit vorhanden, die diesen Header benutzt und es passiert genau das, was du beobachtest.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2277040</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2277040</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 04 Dec 2012 10:42:16 GMT</pubDate></item><item><title><![CDATA[Reply to mehrfach definiertes Symbol gefunden on Tue, 04 Dec 2012 12:33:44 GMT]]></title><description><![CDATA[<p>dass inline definitionen in den header können war mir klar, deswegen hab ichs auch so gemacht. aber wieso geht das trotzdem nicht? muss ich für jede winzige funktion diesen aufwand betreiben und das in die cpp datei machen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2277072</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2277072</guid><dc:creator><![CDATA[Francis123]]></dc:creator><pubDate>Tue, 04 Dec 2012 12:33:44 GMT</pubDate></item><item><title><![CDATA[Reply to mehrfach definiertes Symbol gefunden on Tue, 04 Dec 2012 12:37:16 GMT]]></title><description><![CDATA[<p>Nikolai schrieb:</p>
<blockquote>
<p>dass inline definitionen in den header können war mir klar, deswegen hab ichs auch so gemacht.</p>
</blockquote>
<p>Ich sehe nichts inline bei den fraglichen Funktionen. Der Compiler anscheinend auch nicht. Was glaubst du, wer wohl Recht hat?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2277074</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2277074</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Tue, 04 Dec 2012 12:37:16 GMT</pubDate></item><item><title><![CDATA[Reply to mehrfach definiertes Symbol gefunden on Tue, 04 Dec 2012 12:56:56 GMT]]></title><description><![CDATA[<p>Nikolai schrieb:</p>
<blockquote>
<p>hier ist Global.h:</p>
<pre><code>#ifndef _GLOBAL_H_
#define _GLOBAL_H_
#include &quot;Cout.h&quot;

extern Cout cout;

	int getWidth(RECT* r)
	{return r-&gt;right-r-&gt;left;}

	int getHeight(RECT* r)
	{return r-&gt;bottom-r-&gt;top;}

	bool outOfBounds(RECT r, RECT area)
	{
	  return(r.right&gt;area.right || r.left&lt;area.left || r.top&lt;area.top || r.bottom&gt;area.bottom);
	}

	void print(Cout&amp; cout, RECT* r)
	{
		cout&lt;&lt;r-&gt;left&lt;&lt;&quot; / &quot;&lt;&lt;r-&gt;top&lt;&lt;&quot; / &quot;&lt;&lt;r-&gt;right&lt;&lt;&quot; / &quot;&lt;&lt;r-&gt;bottom&lt;&lt;&quot;\n&quot;;
	}

	bool outOfBounds(int x, int y, int w, int h, RECT area)
	{
		RECT r;
		r.left=x; r.top=y; r.right=x+w; r.bottom=y+h;
		return outOfBounds(r,area);
	}

#endif
</code></pre>
</blockquote>
<p>Wenn diese Funktionsdefinitionen wirklich im Header stehen bleiben sollen, dann fehlt da überall das <code>inline</code> Schlüsselwort. Schau nochmal in ein C++ Buch deines Vertrauens zu der &quot;one definition rule&quot; nach.</p>
<p>Und Bezeichner wie _GLOBAL_H_ sind pfui. Wer hat dir erlaubt, diese zu benutzen? Weißt du nicht, dass diese zu Namensräumen gehören, in denen du nichts zu suchen hast? Vergiss am besten alles, was zwei aufeinanderfolgende Unterstriche hat und was mit einem Unterstrich anfängt und mit einem Großbuchstaben weitergeht. All diese Bezeichner sind <em>reserviert für wen anders</em> als dich.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2277080</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2277080</guid><dc:creator><![CDATA[krümelkacker]]></dc:creator><pubDate>Tue, 04 Dec 2012 12:56:56 GMT</pubDate></item><item><title><![CDATA[Reply to mehrfach definiertes Symbol gefunden on Tue, 04 Dec 2012 13:43:47 GMT]]></title><description><![CDATA[<p>Wieso überhaupt** <code>std::</code> ** <code>outOfBounds</code> ? Da scheint irgendwas übelst im Arsch zu sein, bei Dir.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2277089</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2277089</guid><dc:creator><![CDATA[Tachyon]]></dc:creator><pubDate>Tue, 04 Dec 2012 13:43:47 GMT</pubDate></item></channel></rss>