<?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[STL VECTOR Problem]]></title><description><![CDATA[<p>Hallo liebe Leute ich habe ein Problem mit einem static template vector.<br />
Der Compiler meldet mir nämmlich copy-konstruktor nicht erreichbar.<br />
Hier erstmal der Code von der Header:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &quot;mString.h&quot;
using namespace std;

class user;
typedef vector&lt;user,allocator&lt;user&gt; &gt;  user_vector;

class user
{
public:

	user(SOCKET s, SOCKADDR_IN addre,mString name);
    user();
	user(user *a);
	user(user &amp;a);

	bool user::operator&lt;(user &amp;a)
	{
		if(id_nr &lt; a.get_id())
		{
			return true;
		}
		else
			return false;
	}
	bool user::operator==(user &amp;a)
	{
		if(id_nr == a.get_id())
		{
			return true;
		}
		else
			return false;
	}
	user&amp; user::operator=(user &amp;a)
	{

		user_socket = a.get_socket();
		addr        = a.get_addr();
		adresse     = inet_ntoa(addr.sin_addr);
		name        = get_name();
		user_status = true;
		id_nr       = get_id();

		return *this;
	}
	user&amp; user::operator=(SOCKET s)
	{
		this-&gt;user_socket = s;
		return *this;
	}
	user&amp; user::operator=(SOCKADDR_IN addre)
	{

		addr = addre;
        adresse = inet_ntoa(addr.sin_addr);
		return *this;
	}
	user&amp; user::operator=(mString a)
	{
		name = a;
		return *this;
	}
	user&amp; user::operator=(bool status)
	{
		user_status = status;
		return *this;
	}
	user&amp; user::operator=(char *adr)
	{
		adresse = adr;
		return *this;
	}

	bool operator!=(user &amp;a)
	{
		if(id_nr != a.get_id())
		{
			return true;
		}
		else
			return false;
	}

	int get_id();
	SOCKET get_socket();
	SOCKADDR_IN get_addr();
	mString get_name();
    mString get_adresse()
	{
		return adresse;
	}

	void set_socket(SOCKET s);
	void set_addr(SOCKADDR_IN addrs);
	void set_name(mString a);
    int set_id();
   static user_vector userbuf;
private:

	static int  total_number;

	SOCKET user_socket;
	SOCKADDR_IN addr;
	bool user_status;
	mString adresse;
	mString name;
	int id_nr;

};

user_vector user::userbuf;
int user::total_number = 0;
</code></pre>
<p>Hier die Cpp</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;WinSock2.h&gt;
#include &quot;mString.h&quot;
#include &quot;user.h&quot;
using namespace std;

user::user()
{
	user_status = true;
    id_nr = set_id();
}

user::user(user &amp;a)
{
	user_socket = a.get_socket();
	addr        = a.get_addr();
	adresse     = inet_ntoa(addr.sin_addr);
	name        = a.get_name();
	user_status = true;
	id_nr       = a.get_id();

}
user::user(user *a)
{
	user_socket = a-&gt;get_socket(); 
    addr        = a-&gt;get_addr();
    adresse     = inet_ntoa(addr.sin_addr);
    name        = a-&gt;get_name();
    user_status = true;
    id_nr       = a-&gt;get_id();	
}
user::user(SOCKET s,SOCKADDR_IN addre,mString name)
{
	static int id= 0;
	user_socket = s;
	addr = addre;
	adresse = inet_ntoa(addre.sin_addr);
	this-&gt;name = name;
	user_status = true;
    id_nr = set_id();
    ++total_number;
}

SOCKADDR_IN user::get_addr()
{
	return this-&gt;addr;
}

SOCKET user::get_socket()
{
	return this-&gt;user_socket;
}

mString user::get_name()
{

	return name;
}

int user::get_id()
{
	return this-&gt;id_nr;
}

void user::set_addr(SOCKADDR_IN addrs)
{
	addr = addrs;
	adresse = inet_ntoa(addr.sin_addr);
}
int user::set_id()
{
	static int id =0;
	return id++;
}

void user::set_socket(SOCKET s)
{
	user_socket = s;
}

void user::set_name(mString a)
{
  name = a;
}

int function(user a)
{
	user user1;
	user1 = a;

	user::userbuf.push_back(user1);
	return 0;
}
</code></pre>
<p>die funktion function ist eine dummy function welches den fehler simmuliert.<br />
Ich hoffe jemand hat eine lösung dafür danke im vorraus<br />
MFG CF</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/134217/stl-vector-problem</link><generator>RSS for Node</generator><lastBuildDate>Fri, 28 Aug 2026 11:42:37 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/134217.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 24 Jan 2006 15:55:01 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to STL VECTOR Problem on Tue, 24 Jan 2006 15:55:01 GMT]]></title><description><![CDATA[<p>Hallo liebe Leute ich habe ein Problem mit einem static template vector.<br />
Der Compiler meldet mir nämmlich copy-konstruktor nicht erreichbar.<br />
Hier erstmal der Code von der Header:</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &quot;mString.h&quot;
using namespace std;

class user;
typedef vector&lt;user,allocator&lt;user&gt; &gt;  user_vector;

class user
{
public:

	user(SOCKET s, SOCKADDR_IN addre,mString name);
    user();
	user(user *a);
	user(user &amp;a);

	bool user::operator&lt;(user &amp;a)
	{
		if(id_nr &lt; a.get_id())
		{
			return true;
		}
		else
			return false;
	}
	bool user::operator==(user &amp;a)
	{
		if(id_nr == a.get_id())
		{
			return true;
		}
		else
			return false;
	}
	user&amp; user::operator=(user &amp;a)
	{

		user_socket = a.get_socket();
		addr        = a.get_addr();
		adresse     = inet_ntoa(addr.sin_addr);
		name        = get_name();
		user_status = true;
		id_nr       = get_id();

		return *this;
	}
	user&amp; user::operator=(SOCKET s)
	{
		this-&gt;user_socket = s;
		return *this;
	}
	user&amp; user::operator=(SOCKADDR_IN addre)
	{

		addr = addre;
        adresse = inet_ntoa(addr.sin_addr);
		return *this;
	}
	user&amp; user::operator=(mString a)
	{
		name = a;
		return *this;
	}
	user&amp; user::operator=(bool status)
	{
		user_status = status;
		return *this;
	}
	user&amp; user::operator=(char *adr)
	{
		adresse = adr;
		return *this;
	}

	bool operator!=(user &amp;a)
	{
		if(id_nr != a.get_id())
		{
			return true;
		}
		else
			return false;
	}

	int get_id();
	SOCKET get_socket();
	SOCKADDR_IN get_addr();
	mString get_name();
    mString get_adresse()
	{
		return adresse;
	}

	void set_socket(SOCKET s);
	void set_addr(SOCKADDR_IN addrs);
	void set_name(mString a);
    int set_id();
   static user_vector userbuf;
private:

	static int  total_number;

	SOCKET user_socket;
	SOCKADDR_IN addr;
	bool user_status;
	mString adresse;
	mString name;
	int id_nr;

};

user_vector user::userbuf;
int user::total_number = 0;
</code></pre>
<p>Hier die Cpp</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;WinSock2.h&gt;
#include &quot;mString.h&quot;
#include &quot;user.h&quot;
using namespace std;

user::user()
{
	user_status = true;
    id_nr = set_id();
}

user::user(user &amp;a)
{
	user_socket = a.get_socket();
	addr        = a.get_addr();
	adresse     = inet_ntoa(addr.sin_addr);
	name        = a.get_name();
	user_status = true;
	id_nr       = a.get_id();

}
user::user(user *a)
{
	user_socket = a-&gt;get_socket(); 
    addr        = a-&gt;get_addr();
    adresse     = inet_ntoa(addr.sin_addr);
    name        = a-&gt;get_name();
    user_status = true;
    id_nr       = a-&gt;get_id();	
}
user::user(SOCKET s,SOCKADDR_IN addre,mString name)
{
	static int id= 0;
	user_socket = s;
	addr = addre;
	adresse = inet_ntoa(addre.sin_addr);
	this-&gt;name = name;
	user_status = true;
    id_nr = set_id();
    ++total_number;
}

SOCKADDR_IN user::get_addr()
{
	return this-&gt;addr;
}

SOCKET user::get_socket()
{
	return this-&gt;user_socket;
}

mString user::get_name()
{

	return name;
}

int user::get_id()
{
	return this-&gt;id_nr;
}

void user::set_addr(SOCKADDR_IN addrs)
{
	addr = addrs;
	adresse = inet_ntoa(addr.sin_addr);
}
int user::set_id()
{
	static int id =0;
	return id++;
}

void user::set_socket(SOCKET s)
{
	user_socket = s;
}

void user::set_name(mString a)
{
  name = a;
}

int function(user a)
{
	user user1;
	user1 = a;

	user::userbuf.push_back(user1);
	return 0;
}
</code></pre>
<p>die funktion function ist eine dummy function welches den fehler simmuliert.<br />
Ich hoffe jemand hat eine lösung dafür danke im vorraus<br />
MFG CF</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975096</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975096</guid><dc:creator><![CDATA[Ceeeefffffff]]></dc:creator><pubDate>Tue, 24 Jan 2006 15:55:01 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Tue, 24 Jan 2006 16:23:57 GMT]]></title><description><![CDATA[<p>Der benötigte Copy-Konstruktor hat AFAIK die Signatur Typ (<strong>const</strong> Typ&amp;).</p>
<p>BTW, niemals using namespace im Header!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975125</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975125</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Tue, 24 Jan 2006 16:23:57 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Tue, 24 Jan 2006 16:34:48 GMT]]></title><description><![CDATA[<p>Oder wie soll der Copy-Constructor aussehen<br />
und was ist bitte schön AFAIK .</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975132</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975132</guid><dc:creator><![CDATA[Cefour]]></dc:creator><pubDate>Tue, 24 Jan 2006 16:34:48 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Tue, 24 Jan 2006 16:52:04 GMT]]></title><description><![CDATA[<p>Cefour schrieb:</p>
<blockquote>
<p>Oder wie soll der Copy-Constructor aussehen</p>
</blockquote>
<p>Wie bitte? <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>Cefour schrieb:</p>
<blockquote>
<p>und was ist bitte schön AFAIK .</p>
</blockquote>
<p><a href="https://www.google.de/search?&amp;q=AFAIK" rel="nofollow">Google: AFAIK</a> <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/975150</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975150</guid><dc:creator><![CDATA[michba]]></dc:creator><pubDate>Tue, 24 Jan 2006 16:52:04 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Tue, 24 Jan 2006 17:01:19 GMT]]></title><description><![CDATA[<p>Hi ich wollte nur wissen wie der Funktionskopf des Copy Konstructor aussehne soll.</p>
<p>So ich hab noch mir selber eine versuchs Klasse geschrieben wo das klappt.<br />
Und ich weiss nicht warum das bei dieser Klasse klappt und bei der anderen nicht. Könnte mir jemand ne antwort darauf geben</p>
<p>#include &lt;vector&gt;<br />
#include &lt;iostream&gt;<br />
#include &lt;Windows.h&gt;<br />
#include &lt;stdio.h&gt;<br />
#include &lt;stdlib.h&gt;<br />
using namespace std;<br />
class versuch;<br />
typedef vector&lt;versuch,allocator&lt;versuch&gt; &gt; versuchvector;</p>
<p>class versuch<br />
{<br />
public:<br />
versuch()<br />
{<br />
strcpy(name,&quot;Hallo&quot;);<br />
}<br />
versuch(versuch *a)<br />
{<br />
strcpy(name ,a-&gt;name);<br />
}</p>
<p>~versuch()<br />
{<br />
}<br />
static versuchvector vvv;<br />
char name[10];</p>
<p>};</p>
<p>versuchvector versuch::vvv;</p>
<p>int main()<br />
{</p>
<p>versuch versuch1;<br />
versuch::vvv.push_back(versuch1);<br />
cout&lt;&lt;versuch::vvv[0].name;<br />
int a;<br />
cin&gt;&gt;a;<br />
return 0;<br />
}<br />
[/code]</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975159</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975159</guid><dc:creator><![CDATA[Cefour]]></dc:creator><pubDate>Tue, 24 Jan 2006 17:01:19 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Tue, 24 Jan 2006 17:12:58 GMT]]></title><description><![CDATA[<p>.filmor schrieb:</p>
<blockquote>
<p>Der benötigte Copy-Konstruktor hat AFAIK die Signatur Typ (<strong>const</strong> Typ&amp;).</p>
</blockquote>
<p>Nein, denn siehe Standard 12.8 2 (Auszug)</p>
<blockquote>
<p>A nontemplate constructor for class X is a copy constructor if its first parameter is of type X&amp;, const X&amp;, volatile X&amp; or const volatile X&amp;, and either there are no other parameters or else all other parameters have default arguments (8.3.6).</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/975175</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975175</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Tue, 24 Jan 2006 17:12:58 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Tue, 24 Jan 2006 17:14:37 GMT]]></title><description><![CDATA[<p>Mkay</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975179</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975179</guid><dc:creator><![CDATA[.filmor]]></dc:creator><pubDate>Tue, 24 Jan 2006 17:14:37 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Tue, 24 Jan 2006 17:19:09 GMT]]></title><description><![CDATA[<p>Wo ist das Problem in meiner Klasse?????????<br />
Und wie seht der Funktionskopf aus um eine für die Vector Datenstruktur eine angmessenen CopyKonstruktor zu übergeben</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975185</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975185</guid><dc:creator><![CDATA[Cefour]]></dc:creator><pubDate>Tue, 24 Jan 2006 17:19:09 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Wed, 25 Jan 2006 09:57:30 GMT]]></title><description><![CDATA[<p>Na toll. ich hatte auch mal so ein ähnliches problem!!!!!<br />
Habe aber keine Lösung gefunden vielleicht hat ja einer von euch ne lösung</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975688</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975688</guid><dc:creator><![CDATA[Minas]]></dc:creator><pubDate>Wed, 25 Jan 2006 09:57:30 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Wed, 25 Jan 2006 10:10:39 GMT]]></title><description><![CDATA[<p>Cefour schrieb:</p>
<blockquote>
<p>Wo ist das Problem in meiner Klasse?????????</p>
</blockquote>
<p>Das hat .filmor doch schon in seinem ersten Beitrag geschrieben.</p>
<blockquote>
<p>Und wie seht der Funktionskopf aus um eine für die Vector Datenstruktur eine angmessenen CopyKonstruktor zu übergeben</p>
</blockquote>
<p>Schaffst du es nicht, an der passende Stelle ein const einzufügen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975708</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975708</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Wed, 25 Jan 2006 10:10:39 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Wed, 25 Jan 2006 10:36:44 GMT]]></title><description><![CDATA[<p>Wenn da ein const notwendig ist, ist der Compiler nicht standardkonform (siehe mein Post).</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975733</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975733</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Wed, 25 Jan 2006 10:36:44 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Wed, 25 Jan 2006 10:47:16 GMT]]></title><description><![CDATA[<p>Was ist denn 'allocator&lt;&gt;'? Wenn das die Standard-Allokatorklasse ist, kannst du sie bei der Definition auch weglassen.</p>
<p>Zweitens: Wozu brauchst du dort den &lt;iostream&gt;-Header?</p>
<p>Drittens: Pack' die Definition der statischen Elemente lieber in die &quot;user.cpp&quot;, sonst bekommst du später Linker-Fehler.</p>
<p>Viertens: Wie lautet der genaue Wortlaut des Fehlers und in wlecher Zeile tritt er auf?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975744</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975744</guid><dc:creator><![CDATA[CStoll (off)]]></dc:creator><pubDate>Wed, 25 Jan 2006 10:47:16 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Wed, 25 Jan 2006 10:55:30 GMT]]></title><description><![CDATA[<p>Braunstein schrieb:</p>
<blockquote>
<p>Wenn da ein const notwendig ist, ist der Compiler nicht standardkonform (siehe mein Post).</p>
</blockquote>
<p>Wie kommst du darauf? 20.1.3. erfordert doch IMHO ausdrücklich die Äquivalenz bei einer Erzeugung aus const T.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975749</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975749</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Wed, 25 Jan 2006 10:55:30 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Wed, 25 Jan 2006 11:27:45 GMT]]></title><description><![CDATA[<p>Er erzeugt doch aber garnicht aus const T oder übersehe ich hier was?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975772</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975772</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Wed, 25 Jan 2006 11:27:45 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Wed, 25 Jan 2006 11:53:17 GMT]]></title><description><![CDATA[<p>Braunstein schrieb:</p>
<blockquote>
<p>Er erzeugt doch aber garnicht aus const T oder übersehe ich hier was?</p>
</blockquote>
<p>Der Elementtyp von std::vector muss die Eigenschaft &quot;copyconstructible&quot; erfüllen, und das beinhaltet Konstruierbarkeit aus const T.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975787</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975787</guid><dc:creator><![CDATA[MFK]]></dc:creator><pubDate>Wed, 25 Jan 2006 11:53:17 GMT</pubDate></item><item><title><![CDATA[Reply to STL VECTOR Problem on Wed, 25 Jan 2006 12:11:50 GMT]]></title><description><![CDATA[<p>Ok, jetzt ist alles klar. Ich hab doch glatt übersehen, dass push_back const T&amp; als Argument übernimmt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/975799</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/975799</guid><dc:creator><![CDATA[Braunstein]]></dc:creator><pubDate>Wed, 25 Jan 2006 12:11:50 GMT</pubDate></item></channel></rss>