<?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[Compiler schmeisst fehler raus,templates classen &amp;amp; vectoren]]></title><description><![CDATA[<p>jo hallo also hier der code...</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
using namespace std;

class Student
{
public:
		Student();
		Student(const string&amp; name, const int age);
		Student(const Student&amp; rhs);
		~Student();

		void SetName(const string&amp; name);
		string GetName() const;
		void SetAge(const int age);
		int GetAge() const;

		Student&amp; operator=(const Student&amp; rhs);
private:
		string itsName;
		int itsAge;
};

Student::Student()
: itsName(&quot;Neuer Schueler&quot;),itsAge(16)
{}

Student::Student(const string&amp; name, const int age)
: itsName(name),itsAge(age)
{}

Student::Student(const Student&amp; rhs)
:itsName(rhs.GetName()),itsAge(rhs.GetAge())
{}

Student::~Student()
{}

void Student::SetName(const string&amp; name)
{
	itsName=name;
}
string Student::GetName() const
{
	return itsName;
}

void Student::SetAge(const int age)
{
	itsAge=age;
}

int Student::GetAge() const
{
	return itsAge;
}

Student&amp; Student::operator=(const Student&amp; rhs)
{
	itsName=rhs.GetName();
	itsAge=rhs.GetAge();
	return *this;
}

ostream&amp; operator&lt;&lt;(ostream&amp; os,const Student&amp; rhs)
{
	os&lt;&lt;rhs.GetName()&lt;&lt;&quot; ist &quot;&lt;&lt;rhs.GetAge()&lt;&lt;&quot; Jahre alt&quot;;
	return os;
}

template&lt;class T&gt;
void ShowVector(const vector&lt;T&gt;&amp; v);

typedef vector&lt;Student&gt; SchoolClass;

int main()
{
	Student Harry;
	Student Sally(&quot;Sally&quot;,15);
	Student Bill(&quot;Bill&quot;,17);
	Student Peter(&quot;Peter&quot;,16);

	SchoolClass EmptyClass;
	cout &lt;&lt;&quot;Leere Klasse:\n&quot;;
	ShowVector(EmptyClass);

	SchoolClass GrowingClass(3);
	cout &lt;&lt; &quot;Wachsende Klasse(3):\n&quot;;
	ShowVector(GrowingClass);

	GrowingClass[0]=Harry;
	GrowingClass[1]=Sally;
	GrowingClass[2]=Bill;
	cout&lt;&lt;&quot; WachsendeKlasse(3) nach Zuweisung von Schuelern:\n&quot;;
	ShowVector(GrowingClass);

	GrowingClass.push_back(Peter);
	cout&lt;&lt;&quot;Wachsende KLasse nach Zuweisung des 4ten Schuelers\n:&quot;;
	ShowVector(GrowingClass);

	GrowingClass[0].SetName(&quot;Harry&quot;);
	GrowingClass[0].SetAge(18);
	cout&lt;&lt;&quot;Wachsende Klasse nach eintragung des namens\n:&quot;;
	ShowVector(GrowingClass);
	return 0;

}

template&lt;class T&gt;
void ShowVector(const vector&lt;T&gt;&amp; v)
{ 
	unsigned int i;
	cout&lt;&lt;&quot;max_size()=&quot; &lt;&lt; v.max_size();
	cout&lt;&lt;&quot;\tsize()=&quot;&lt;&lt;v.size();
	cout&lt;&lt;&quot;\tcapacity()=&quot;&lt;&lt;v.capacity();
	cout&lt;&lt;&quot;\t&quot;&lt;&lt;(v.empty()? &quot;leer&quot;:&quot;nicht leer&quot;);
	cout&lt;&lt;&quot;\n&quot;;
	for( i=0;i&lt;v.size();++i)
		cout &lt;&lt; v[i]&lt;&lt;&quot;\n&quot;;
	cout&lt;&lt;endl;

}
</code></pre>
<p>da schmeisst der compiler folgenden fehler raus:</p>
<blockquote>
<p>Linking...</p>
<p>C:\...\testclass\Debug\testclass.o(.text$_ZNSt14__simple_allocI7StudentSt24__default_alloc_templateILb1ELi0EEE10deallocateEPS0_j+0x1d): In function `ZN7StudentC2Ev':</p>
<p>C:\...\testclass\testclass.cpp:26: undefined reference to `std::__default_alloc_template&lt;true, 0&gt;::deallocate(void*, unsigned)'</p>
<p>C:\...\testclass\Debug\testclass.o(.text$_ZNSt14__simple_allocI7StudentSt24__default_alloc_templateILb1ELi0EEE8allocateEj+0x1d):C:\Dokumente und Einstellungen\Tutor\Desktop\svn\transistor_kennlinien\testclass\testclass.cpp:26: undefined reference to `std::__default_alloc_template&lt;true, 0&gt;::allocate(unsigned)'</p>
<p>testclass.exe - 2 error(s), 0 warning(s)</p>
</blockquote>
<p>ändere ich folgendes:</p>
<p>void ShowVector(const vector&lt;T&gt;&amp; v)<br />
{</p>
<pre><code class="language-cpp">unsigned int i;
</code></pre>
<p>cout&lt;&lt;&quot;max_size()=&quot; &lt;&lt; v.max_size();<br />
cout&lt;&lt;&quot;\tsize()=&quot;&lt;&lt;v.</p>
<p>zu:<br />
void ShowVector(const vector&lt;T&gt;&amp; v)<br />
{</p>
<pre><code class="language-cpp">signed int i;
</code></pre>
<p>cout&lt;&lt;&quot;max_size()=&quot; &lt;&lt; v.max_size();<br />
cout&lt;&lt;&quot;\tsize()=&quot;&lt;&lt;v.<br />
bekomme ich folgenden fehler:</p>
<blockquote>
<p>Compiling source file(s)...</p>
<p>testclass.cpp</p>
<p>testclass.cpp: In function `void ShowVector(const std::vector&lt;T,<br />
std::allocator&lt;_CharT&gt; &gt;&amp;) [with T = Student]':<br />
testclass.cpp:86: instantiated from here</p>
<p>testclass.cpp:119: warning: comparison between signed and unsigned integer<br />
expressions</p>
<p>testclass.exe - 1 error(s), 1 warning(s)</p>
</blockquote>
<p>hmmmmm,.... wieso?? wie änder ich das ab???<br />
also ich benutze MinGW Dev Studio...</p>
<p>thx for help <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/topic/167252/compiler-schmeisst-fehler-raus-templates-classen-amp-vectoren</link><generator>RSS for Node</generator><lastBuildDate>Tue, 15 Sep 2026 23:42:30 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/167252.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 08 Dec 2006 17:31:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Compiler schmeisst fehler raus,templates classen &amp;amp; vectoren on Fri, 08 Dec 2006 17:31:19 GMT]]></title><description><![CDATA[<p>jo hallo also hier der code...</p>
<pre><code class="language-cpp">#include &lt;iostream&gt;
#include &lt;string&gt;
#include &lt;vector&gt;
using namespace std;

class Student
{
public:
		Student();
		Student(const string&amp; name, const int age);
		Student(const Student&amp; rhs);
		~Student();

		void SetName(const string&amp; name);
		string GetName() const;
		void SetAge(const int age);
		int GetAge() const;

		Student&amp; operator=(const Student&amp; rhs);
private:
		string itsName;
		int itsAge;
};

Student::Student()
: itsName(&quot;Neuer Schueler&quot;),itsAge(16)
{}

Student::Student(const string&amp; name, const int age)
: itsName(name),itsAge(age)
{}

Student::Student(const Student&amp; rhs)
:itsName(rhs.GetName()),itsAge(rhs.GetAge())
{}

Student::~Student()
{}

void Student::SetName(const string&amp; name)
{
	itsName=name;
}
string Student::GetName() const
{
	return itsName;
}

void Student::SetAge(const int age)
{
	itsAge=age;
}

int Student::GetAge() const
{
	return itsAge;
}

Student&amp; Student::operator=(const Student&amp; rhs)
{
	itsName=rhs.GetName();
	itsAge=rhs.GetAge();
	return *this;
}

ostream&amp; operator&lt;&lt;(ostream&amp; os,const Student&amp; rhs)
{
	os&lt;&lt;rhs.GetName()&lt;&lt;&quot; ist &quot;&lt;&lt;rhs.GetAge()&lt;&lt;&quot; Jahre alt&quot;;
	return os;
}

template&lt;class T&gt;
void ShowVector(const vector&lt;T&gt;&amp; v);

typedef vector&lt;Student&gt; SchoolClass;

int main()
{
	Student Harry;
	Student Sally(&quot;Sally&quot;,15);
	Student Bill(&quot;Bill&quot;,17);
	Student Peter(&quot;Peter&quot;,16);

	SchoolClass EmptyClass;
	cout &lt;&lt;&quot;Leere Klasse:\n&quot;;
	ShowVector(EmptyClass);

	SchoolClass GrowingClass(3);
	cout &lt;&lt; &quot;Wachsende Klasse(3):\n&quot;;
	ShowVector(GrowingClass);

	GrowingClass[0]=Harry;
	GrowingClass[1]=Sally;
	GrowingClass[2]=Bill;
	cout&lt;&lt;&quot; WachsendeKlasse(3) nach Zuweisung von Schuelern:\n&quot;;
	ShowVector(GrowingClass);

	GrowingClass.push_back(Peter);
	cout&lt;&lt;&quot;Wachsende KLasse nach Zuweisung des 4ten Schuelers\n:&quot;;
	ShowVector(GrowingClass);

	GrowingClass[0].SetName(&quot;Harry&quot;);
	GrowingClass[0].SetAge(18);
	cout&lt;&lt;&quot;Wachsende Klasse nach eintragung des namens\n:&quot;;
	ShowVector(GrowingClass);
	return 0;

}

template&lt;class T&gt;
void ShowVector(const vector&lt;T&gt;&amp; v)
{ 
	unsigned int i;
	cout&lt;&lt;&quot;max_size()=&quot; &lt;&lt; v.max_size();
	cout&lt;&lt;&quot;\tsize()=&quot;&lt;&lt;v.size();
	cout&lt;&lt;&quot;\tcapacity()=&quot;&lt;&lt;v.capacity();
	cout&lt;&lt;&quot;\t&quot;&lt;&lt;(v.empty()? &quot;leer&quot;:&quot;nicht leer&quot;);
	cout&lt;&lt;&quot;\n&quot;;
	for( i=0;i&lt;v.size();++i)
		cout &lt;&lt; v[i]&lt;&lt;&quot;\n&quot;;
	cout&lt;&lt;endl;

}
</code></pre>
<p>da schmeisst der compiler folgenden fehler raus:</p>
<blockquote>
<p>Linking...</p>
<p>C:\...\testclass\Debug\testclass.o(.text$_ZNSt14__simple_allocI7StudentSt24__default_alloc_templateILb1ELi0EEE10deallocateEPS0_j+0x1d): In function `ZN7StudentC2Ev':</p>
<p>C:\...\testclass\testclass.cpp:26: undefined reference to `std::__default_alloc_template&lt;true, 0&gt;::deallocate(void*, unsigned)'</p>
<p>C:\...\testclass\Debug\testclass.o(.text$_ZNSt14__simple_allocI7StudentSt24__default_alloc_templateILb1ELi0EEE8allocateEj+0x1d):C:\Dokumente und Einstellungen\Tutor\Desktop\svn\transistor_kennlinien\testclass\testclass.cpp:26: undefined reference to `std::__default_alloc_template&lt;true, 0&gt;::allocate(unsigned)'</p>
<p>testclass.exe - 2 error(s), 0 warning(s)</p>
</blockquote>
<p>ändere ich folgendes:</p>
<p>void ShowVector(const vector&lt;T&gt;&amp; v)<br />
{</p>
<pre><code class="language-cpp">unsigned int i;
</code></pre>
<p>cout&lt;&lt;&quot;max_size()=&quot; &lt;&lt; v.max_size();<br />
cout&lt;&lt;&quot;\tsize()=&quot;&lt;&lt;v.</p>
<p>zu:<br />
void ShowVector(const vector&lt;T&gt;&amp; v)<br />
{</p>
<pre><code class="language-cpp">signed int i;
</code></pre>
<p>cout&lt;&lt;&quot;max_size()=&quot; &lt;&lt; v.max_size();<br />
cout&lt;&lt;&quot;\tsize()=&quot;&lt;&lt;v.<br />
bekomme ich folgenden fehler:</p>
<blockquote>
<p>Compiling source file(s)...</p>
<p>testclass.cpp</p>
<p>testclass.cpp: In function `void ShowVector(const std::vector&lt;T,<br />
std::allocator&lt;_CharT&gt; &gt;&amp;) [with T = Student]':<br />
testclass.cpp:86: instantiated from here</p>
<p>testclass.cpp:119: warning: comparison between signed and unsigned integer<br />
expressions</p>
<p>testclass.exe - 1 error(s), 1 warning(s)</p>
</blockquote>
<p>hmmmmm,.... wieso?? wie änder ich das ab???<br />
also ich benutze MinGW Dev Studio...</p>
<p>thx for help <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1188873</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1188873</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Fri, 08 Dec 2006 17:31:19 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler schmeisst fehler raus,templates classen &amp;amp; vectoren on Fri, 08 Dec 2006 22:18:27 GMT]]></title><description><![CDATA[<p>Der Code kompiliert bei mir mit dem gcc 3.4.6 fehlerfrei.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1188912</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1188912</guid><dc:creator><![CDATA[KPC]]></dc:creator><pubDate>Fri, 08 Dec 2006 22:18:27 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler schmeisst fehler raus,templates classen &amp;amp; vectoren on Fri, 08 Dec 2006 22:25:50 GMT]]></title><description><![CDATA[<p>Der erste Fehler ist offensichtlich ein Link-Fehler (d.h. der Code wurde bereits erfolgreich compiliert). Deine Änderungen haben einen Compile-Fehler erzeugt, so daß es überhaupt nicht mehr zum Linken kommt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1188915</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1188915</guid><dc:creator><![CDATA[Z2]]></dc:creator><pubDate>Fri, 08 Dec 2006 22:25:50 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler schmeisst fehler raus,templates classen &amp;amp; vectoren on Fri, 08 Dec 2006 23:44:03 GMT]]></title><description><![CDATA[<p>wenn der erste ein linkfehler ist, wie was muss ich da neu verlinken??<br />
thx &amp; mfg :xmas2:</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1188931</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1188931</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Fri, 08 Dec 2006 23:44:03 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler schmeisst fehler raus,templates classen &amp;amp; vectoren on Sun, 10 Dec 2006 18:50:12 GMT]]></title><description><![CDATA[<p>kann mir keiner helfe???<br />
<img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f61e.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--disappointed_face"
      title=":("
      alt="😞"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1189707</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1189707</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Sun, 10 Dec 2006 18:50:12 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler schmeisst fehler raus,templates classen &amp;amp; vectoren on Mon, 11 Dec 2006 13:49:46 GMT]]></title><description><![CDATA[<p>Definier mal deine template-Funktion &quot;ShowVector&quot; vor der Benutzung, also vor der &quot;main&quot;-Funktion</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1190115</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1190115</guid><dc:creator><![CDATA[~Th]]></dc:creator><pubDate>Mon, 11 Dec 2006 13:49:46 GMT</pubDate></item><item><title><![CDATA[Reply to Compiler schmeisst fehler raus,templates classen &amp;amp; vectoren on Mon, 11 Dec 2006 17:35:07 GMT]]></title><description><![CDATA[<p>k,. also aus:</p>
<pre><code class="language-cpp">template&lt;class T&gt;
void ShowVector(const vector&lt;T&gt;&amp; v);

typedef vector&lt;Student&gt; SchoolClass;

int main()
{...
</code></pre>
<p>wurde jetzt:</p>
<pre><code class="language-cpp">template&lt;class T&gt;
void ShowVector(const vector&lt;T&gt;&amp; v)
{ 
	unsigned int i;
	cout&lt;&lt;&quot;max_size()=&quot; &lt;&lt; v.max_size();
	cout&lt;&lt;&quot;\tsize()=&quot;&lt;&lt;v.size();
	cout&lt;&lt;&quot;\tcapacity()=&quot;&lt;&lt;v.capacity();
	cout&lt;&lt;&quot;\t&quot;&lt;&lt;(v.empty()? &quot;leer&quot;:&quot;nicht leer&quot;);
	cout&lt;&lt;&quot;\n&quot;;
	for( i=0;i&lt;v.size();++i)
		cout &lt;&lt; v[i]&lt;&lt;&quot;\n&quot;;
	cout&lt;&lt;endl;

}

typedef vector&lt;Student&gt; SchoolClass;

int main()
{...
</code></pre>
<p>folgender fehler taucht auf:</p>
<blockquote>
<p>--------------------Configuration: testclass - Debug--------------------<br />
Compiling source file(s)...<br />
testclass.cpp<br />
Linking...<br />
C:\Dokumente und Einstellungen\Tutor\Desktop\svn\transistor_kennlinien\testclass\Debug\testclass.o(.text\_ZNSt14\_\_simple\_allocI7StudentSt24\_\_default\_alloc\_templateILb1ELi0EEE10deallocateEPS0\_j+0x1d): In function `ZN7StudentC2Ev':  
C:\\Dokumente und Einstellungen\\Tutor\\Desktop\\svn\\transistor\_kennlinien\\testclass\\testclass.cpp:26: undefined reference to `std::\_\_default\_alloc\_template<true, 0>::deallocate(void*, unsigned)'  
C:\\Dokumente und Einstellungen\\Tutor\\Desktop\\svn\\transistor\_kennlinien\\testclass\\Debug\\testclass.o(.text_ZNSt14__simple_allocI7StudentSt24__default_alloc_templateILb1ELi0EEE8allocateEj+0x1d):C:\Dokumente und Einstellungen\Tutor\Desktop\svn\transistor_kennlinien\testclass\testclass.cpp:26: undefined reference to `std::__default_alloc_template&lt;true, 0&gt;::allocate(unsigned)'</p>
<p>testclass.exe - 2 error(s), 0 warning(s)</p>
</blockquote>
<p>wobei die fehlermeldung sich auf zeile 26 bezieht:</p>
<pre><code class="language-cpp">Student::Student()
: itsName(&quot;Neuer Schueler&quot;),itsAge(16)
{}
</code></pre>
<p>hmmmm..... <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
<p>____________________________________________________________________________-<br />
edit:<br />
also mit visual c++ express funzt ditte,.. aber why net minGW??<br />
edit2:<br />
und mit dev-c++ 4.9.9 auch... hmmmm <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f615.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--confused_face"
      title=":confused:"
      alt="😕"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/1190144</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1190144</guid><dc:creator><![CDATA[zeusosc]]></dc:creator><pubDate>Mon, 11 Dec 2006 17:35:07 GMT</pubDate></item></channel></rss>