<?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[komplizierte vererbung]]></title><description><![CDATA[<pre><code class="language-cpp">//test.h

class CObject {
protected:
	static DWORD	m_dwObjectSize;			// size in bytes of all objects

	virtual void IncObjectSize() = 0;			// increase the number of objects size
	virtual void DecObjectSize() = 0;			// decrease the number of objects size

public:
CObject(){};
~CObject(){};
};

template &lt;typename T&gt;
class testbase: public CObject {
	void IncObjectSize();
	void DecObjectSize();

protected:
	T	m_var;

public:
	explicit testbase(const T&amp; value): m_var(value) {};
	virtual ~testbase() {};

        T&amp; operator=(const T&amp; obj);
};

class test: public testbase&lt;int&gt; {
public:
	test(): testbase(0) {};
	~test() {};
	int get() const { return this-&gt;m_var; };
};

// test.cpp
DWORD	CObject::m_dwObjectSize		= 0;

template&lt;typename T&gt;
void testbase&lt;T&gt;::IncObjectSize() {
	m_dwObjectSize		+= sizeof(T);
}

template&lt;typename T&gt;
void testbase&lt;T&gt;::DecObjectSize() {
	m_dwObjectSize		-= sizeof(T);
}

template&lt;typename T&gt;
T&amp; testbase&lt;T&gt;::operator=(const T&amp; value) {

}
</code></pre>
<p>hier hab ich link fehler</p>
<blockquote>
<p>Error 1 error LNK2001: unresolved external symbol &quot;private: virtual void __thiscall testbase&lt;int&gt;::DecObjectSize(void)&quot; (?DecObjectSize@?testbase@H@@EAEXXZ) main.obj testprj  
Error 2 error LNK2001: unresolved external symbol "private: virtual void __thiscall testbase<int>::IncObjectSize(void)" (?IncObjectSize@?testbase@H@@EAEXXZ) main.obj testprj</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/topic/250274/komplizierte-vererbung</link><generator>RSS for Node</generator><lastBuildDate>Wed, 16 Sep 2026 02:23:08 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/250274.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 16 Sep 2009 07:19:22 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to komplizierte vererbung on Wed, 16 Sep 2009 07:31:35 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">//test.h

class CObject {
protected:
	static DWORD	m_dwObjectSize;			// size in bytes of all objects

	virtual void IncObjectSize() = 0;			// increase the number of objects size
	virtual void DecObjectSize() = 0;			// decrease the number of objects size

public:
CObject(){};
~CObject(){};
};

template &lt;typename T&gt;
class testbase: public CObject {
	void IncObjectSize();
	void DecObjectSize();

protected:
	T	m_var;

public:
	explicit testbase(const T&amp; value): m_var(value) {};
	virtual ~testbase() {};

        T&amp; operator=(const T&amp; obj);
};

class test: public testbase&lt;int&gt; {
public:
	test(): testbase(0) {};
	~test() {};
	int get() const { return this-&gt;m_var; };
};

// test.cpp
DWORD	CObject::m_dwObjectSize		= 0;

template&lt;typename T&gt;
void testbase&lt;T&gt;::IncObjectSize() {
	m_dwObjectSize		+= sizeof(T);
}

template&lt;typename T&gt;
void testbase&lt;T&gt;::DecObjectSize() {
	m_dwObjectSize		-= sizeof(T);
}

template&lt;typename T&gt;
T&amp; testbase&lt;T&gt;::operator=(const T&amp; value) {

}
</code></pre>
<p>hier hab ich link fehler</p>
<blockquote>
<p>Error 1 error LNK2001: unresolved external symbol &quot;private: virtual void __thiscall testbase&lt;int&gt;::DecObjectSize(void)&quot; (?DecObjectSize@?testbase@H@@EAEXXZ) main.obj testprj  
Error 2 error LNK2001: unresolved external symbol "private: virtual void __thiscall testbase<int>::IncObjectSize(void)" (?IncObjectSize@?testbase@H@@EAEXXZ) main.obj testprj</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/1779577</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1779577</guid><dc:creator><![CDATA[JnZn558]]></dc:creator><pubDate>Wed, 16 Sep 2009 07:31:35 GMT</pubDate></item><item><title><![CDATA[Reply to komplizierte vererbung on Wed, 16 Sep 2009 07:27:06 GMT]]></title><description><![CDATA[<p>template Implementierungen gehören nicht in ne separate cpp-Datei!!!!<br />
Das gehört in den Header! Außer es sind Spezialisierungen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1779585</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1779585</guid><dc:creator><![CDATA[no_cpp]]></dc:creator><pubDate>Wed, 16 Sep 2009 07:27:06 GMT</pubDate></item><item><title><![CDATA[Reply to komplizierte vererbung on Wed, 16 Sep 2009 07:32:56 GMT]]></title><description><![CDATA[<p>no_cpp schrieb:</p>
<blockquote>
<p>template Implementierungen gehören nicht in ne separate cpp-Datei!!!!<br />
Das gehört in den Header! Außer es sind Spezialisierungen.</p>
</blockquote>
<p>wenn du recht hast, dann muesste der operatorueberladung auch linkfehler verursachen, dies is aber nicht der fall</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1779589</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1779589</guid><dc:creator><![CDATA[JnZn558]]></dc:creator><pubDate>Wed, 16 Sep 2009 07:32:56 GMT</pubDate></item><item><title><![CDATA[Reply to komplizierte vererbung on Wed, 16 Sep 2009 07:35:31 GMT]]></title><description><![CDATA[<p>JnZn558 schrieb:</p>
<blockquote>
<p>wenn du recht hast, dann muesste der operatorueberladung auch linkfehler verursachen, dies is aber nicht der fall</p>
</blockquote>
<p>Er hat aber recht. Pack die Implementierung in die Header-Datei, dann wird es gehen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1779590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1779590</guid><dc:creator><![CDATA[PuppetMaster2k]]></dc:creator><pubDate>Wed, 16 Sep 2009 07:35:31 GMT</pubDate></item><item><title><![CDATA[Reply to komplizierte vererbung on Wed, 16 Sep 2009 07:44:11 GMT]]></title><description><![CDATA[<p>JnZn558 schrieb:</p>
<blockquote>
<p>no_cpp schrieb:</p>
<blockquote>
<p>template Implementierungen gehören nicht in ne separate cpp-Datei!!!!<br />
Das gehört in den Header! Außer es sind Spezialisierungen.</p>
</blockquote>
<p>wenn du recht hast, dann muesste der operatorueberladung auch linkfehler verursachen, dies is aber nicht der fall</p>
</blockquote>
<p>Dann verwende deinen operator= mal. wirst sehen, dann bekommst du deinen Linker-Error!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1779597</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1779597</guid><dc:creator><![CDATA[no_cpp]]></dc:creator><pubDate>Wed, 16 Sep 2009 07:44:11 GMT</pubDate></item><item><title><![CDATA[Reply to komplizierte vererbung on Wed, 16 Sep 2009 07:56:18 GMT]]></title><description><![CDATA[<p>hab IncObjectSize() und DecObjectSize() in die Headerdatei gepackt, und operator=() bleib in cpp datei, und es kompliert problemlos, nun es dies find ich scheiss, dass implementierung in der headerdatei is, wieso geht bei operator, aber bei den andere beide nicht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1779602</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1779602</guid><dc:creator><![CDATA[JnZn558]]></dc:creator><pubDate>Wed, 16 Sep 2009 07:56:18 GMT</pubDate></item><item><title><![CDATA[Reply to komplizierte vererbung on Wed, 16 Sep 2009 08:08:52 GMT]]></title><description><![CDATA[<p>Der Operator geht auch nichzt, du benutzt ihn bloß nicht, weswegen der Linker auch nicht nach dem Symbol sucht.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1779609</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1779609</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 16 Sep 2009 08:08:52 GMT</pubDate></item><item><title><![CDATA[Reply to komplizierte vererbung on Wed, 16 Sep 2009 13:01:32 GMT]]></title><description><![CDATA[<p>JnZn558 schrieb:</p>
<blockquote>
<p>hab IncObjectSize() und DecObjectSize() in die Headerdatei gepackt, und operator=() bleib in cpp datei, und es kompliert problemlos, nun es dies find ich scheiss, dass implementierung in der headerdatei is, wieso geht bei operator, aber bei den andere beide nicht.</p>
</blockquote>
<p>lies doch wenigsten einmal nach, was du geschrieben hast, bevor du auf absenden klickst... wenn nicht jeder schon davor gewusst hätte, was du willst, hätte das hier wahrscheinlich keiner verstanden...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1779780</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1779780</guid><dc:creator><![CDATA[unskilled]]></dc:creator><pubDate>Wed, 16 Sep 2009 13:01:32 GMT</pubDate></item></channel></rss>