<?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[Wird der Copy-Konstruktor implizit eingefügt?]]></title><description><![CDATA[<p>Habe eine Compiler-Fehlermeldung in der mir gesagt wird, dass irgendwas im Copy-Konstruktor nicht korrekt sei. Dabei habe ich in der Klasse garkeinen Copy-Konstruktor definiert. Wird der automatisch eingefügt?</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/271438/wird-der-copy-konstruktor-implizit-eingefügt</link><generator>RSS for Node</generator><lastBuildDate>Sat, 29 Aug 2026 12:59:02 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/271438.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 28 Jul 2010 09:55:56 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Wird der Copy-Konstruktor implizit eingefügt? on Wed, 28 Jul 2010 09:55:56 GMT]]></title><description><![CDATA[<p>Habe eine Compiler-Fehlermeldung in der mir gesagt wird, dass irgendwas im Copy-Konstruktor nicht korrekt sei. Dabei habe ich in der Klasse garkeinen Copy-Konstruktor definiert. Wird der automatisch eingefügt?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1932995</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1932995</guid><dc:creator><![CDATA[HändyÄndy]]></dc:creator><pubDate>Wed, 28 Jul 2010 09:55:56 GMT</pubDate></item><item><title><![CDATA[Reply to Wird der Copy-Konstruktor implizit eingefügt? on Wed, 28 Jul 2010 10:05:46 GMT]]></title><description><![CDATA[<p>HändyÄndy schrieb:</p>
<blockquote>
<p>Habe eine Compiler-Fehlermeldung in der mir gesagt wird, dass irgendwas im Copy-Konstruktor nicht korrekt sei. Dabei habe ich in der Klasse garkeinen Copy-Konstruktor definiert. Wird der automatisch eingefügt?</p>
</blockquote>
<p>Bei Bedarf: Ja.</p>
<p>Was sagt denn die Fehlermeldung? Rate ich richtig, wenn ich annehme, dass einer der Member nicht kopierbar ist?</p>
<p>Ebenso erzeugt werden bei Bedarf ein Konstruktor, Destruktor und Zuweisungsoperator.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1933002</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1933002</guid><dc:creator><![CDATA[SeppJ]]></dc:creator><pubDate>Wed, 28 Jul 2010 10:05:46 GMT</pubDate></item><item><title><![CDATA[Reply to Wird der Copy-Konstruktor implizit eingefügt? on Wed, 28 Jul 2010 10:03:13 GMT]]></title><description><![CDATA[<p>Dank meiner Glaskugel weiß ich zum Glück deine genaue Fehlermeldung und deinen problematischen Code. Und hier die Lösung deines Problems: du musst irgendwas anders machen.</p>
<p>PS: ja der Copy-Ctor wird automatisch erzeugt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1933005</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1933005</guid><dc:creator><![CDATA[ipsec]]></dc:creator><pubDate>Wed, 28 Jul 2010 10:03:13 GMT</pubDate></item><item><title><![CDATA[Reply to Wird der Copy-Konstruktor implizit eingefügt? on Wed, 28 Jul 2010 10:16:13 GMT]]></title><description><![CDATA[<p>In der Tat ist irgendwas nicht kopierbar. Ich denke es ist ein Filehandler (also std::ofstream fileOutput;)</p>
<p>Deshalb habe ich den Code umformuliert. Erhalte nun aber eine für mich völlig unverständliche Compiler-Fehlermeldung.</p>
<pre><code class="language-cpp">class Processor {
	public:
	boost::unordered_map&lt;std::string, std::auto_ptr&lt;StatisticsObject&gt;, boost::hash&lt;std::string&gt; &gt; statisticsObjects;
/*...*/
};

/*...*/

Processor p;
void ddos_init() {
        /*....*/

	//initialisiere die statisticsObjects mit den URLs, die aus der Datei gelesen wurden
	FactorialData factorialData;
	RandomNumberGenerator rng;
	for( boost::unordered_map&lt;std::string, ddos_webpage&gt;::const_iterator it = p.mostImportantWebpages.begin(); it != p.mostImportantWebpages.end(); ++it )
		p.statisticsObjects[it-&gt;first].reset( new StatisticsObject( rng, it-&gt;first, factorialData ) );
}
</code></pre>
<p>Und hier die Klasse StatisticsObject</p>
<pre><code class="language-cpp">class StatisticsObject {

	public:
        /*....*/
	StatisticsObject( RandomNumberGenerator &amp;rng, std::string name, FactorialData &amp;factorialData );
};
</code></pre>
<p>Wenn ich das dann mit make übersetzen will, dann moniert der Compiler folgendes:</p>
<blockquote>
<p>make<br />
g++ -m64 -g -Wall -Werror -Wcomment -I./ -I/usr/src/hend/ -I./boost_1_43_0/include -I./ddos_detector/gsl-1.14/include -o ddos_main.o -c ddos_main.cpp<br />
./boost_1_43_0/include/boost/unordered/detail/util.hpp: In member function ‘void boost::unordered_detail::hash_node_constructor&lt;Alloc, Grouped&gt;::construct_pair(const K&amp;, M*) [with K = std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, M = std::auto_ptr&lt;StatisticsObject&gt;, Alloc = std::allocator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::auto_ptr&lt;StatisticsObject&gt; &gt; &gt;, Grouped = boost::unordered_detail::ungrouped]’:<br />
./boost_1_43_0/include/boost/unordered/detail/unique.hpp:75: instantiated from ‘typename boost::unordered_detail::hash_unique_table&lt;T&gt;::value_type&amp; boost::unordered_detail::hash_unique_table&lt;T&gt;::operator[](const typename T::key_type&amp;) [with T = boost::unordered_detail::map&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, boost::hash&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::equal_to&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::auto_ptr&lt;StatisticsObject&gt; &gt; &gt; &gt;]’<br />
./boost_1_43_0/include/boost/unordered/unordered_map.hpp:406: instantiated from ‘T&amp; boost::unordered_map&lt;K, T, H, P, A&gt;::operator[](const K&amp;) [with K = std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, T = std::auto_ptr&lt;StatisticsObject&gt;, H = boost::hash&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, P = std::equal_to&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, A = std::allocator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::auto_ptr&lt;StatisticsObject&gt; &gt; &gt;]’<br />
ddos_main.cpp:344: instantiated from here<br />
./boost_1_43_0/include/boost/unordered/detail/util.hpp:268: error: no matching function for call to ‘std::auto_ptr&lt;StatisticsObject&gt;::auto_ptr(std::auto_ptr&lt;StatisticsObject&gt;)’<br />
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/memory:349: note: candidates are: std::auto_ptr&lt;_Tp&gt;::auto_ptr(std::auto_ptr_ref&lt;_Tp&gt;) [with _Tp = StatisticsObject]<br />
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/memory:212: note: std::auto_ptr&lt;_Tp&gt;::auto_ptr(std::auto_ptr&lt;_Tp1&gt;&amp;) [with _Tp1 = StatisticsObject, _Tp = StatisticsObject]<br />
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/memory:199: note: std::auto_ptr&lt;_Tp&gt;::auto_ptr(std::auto_ptr&lt;_Tp&gt;&amp;) [with _Tp = StatisticsObject]<br />
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_pair.h: In constructor ‘std::pair&lt;_T1, _T2&gt;::pair(const _T1&amp;, const _T2&amp;) [with _T1 = const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, _T2 = std::auto_ptr&lt;StatisticsObject&gt;]’:<br />
./boost_1_43_0/include/boost/unordered/detail/util.hpp:268: instantiated from ‘void boost::unordered_detail::hash_node_constructor&lt;Alloc, Grouped&gt;::construct_pair(const K&amp;, M*) [with K = std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, M = std::auto_ptr&lt;StatisticsObject&gt;, Alloc = std::allocator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::auto_ptr&lt;StatisticsObject&gt; &gt; &gt;, Grouped = boost::unordered_detail::ungrouped]’<br />
./boost_1_43_0/include/boost/unordered/detail/unique.hpp:75: instantiated from ‘typename boost::unordered_detail::hash_unique_table&lt;T&gt;::value_type&amp; boost::unordered_detail::hash_unique_table&lt;T&gt;::operator[](const typename T::key_type&amp;) [with T = boost::unordered_detail::map&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, boost::hash&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::equal_to&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, std::allocator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::auto_ptr&lt;StatisticsObject&gt; &gt; &gt; &gt;]’<br />
./boost_1_43_0/include/boost/unordered/unordered_map.hpp:406: instantiated from ‘T&amp; boost::unordered_map&lt;K, T, H, P, A&gt;::operator[](const K&amp;) [with K = std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, T = std::auto_ptr&lt;StatisticsObject&gt;, H = boost::hash&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, P = std::equal_to&lt;std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt; &gt;, A = std::allocator&lt;std::pair&lt;const std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, std::auto_ptr&lt;StatisticsObject&gt; &gt; &gt;]’<br />
ddos_main.cpp:344: instantiated from here<br />
/usr/lib/gcc/x86_64-redhat-linux/4.1.2/../../../../include/c++/4.1.2/bits/stl_pair.h:85: error: passing ‘const std::auto_ptr&lt;StatisticsObject&gt;’ as ‘this’ argument of ‘std::auto_ptr&lt;_Tp&gt;::operator std::auto_ptr_ref&lt;_Tp1&gt;() [with _Tp1 = StatisticsObject, _Tp = StatisticsObject]’ discards qualifiers<br />
make: *** [ddos_main.o] Error 1</p>
</blockquote>
<p><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/1933009</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1933009</guid><dc:creator><![CDATA[HändyÄndy]]></dc:creator><pubDate>Wed, 28 Jul 2010 10:16:13 GMT</pubDate></item><item><title><![CDATA[Reply to Wird der Copy-Konstruktor implizit eingefügt? on Wed, 28 Jul 2010 12:10:59 GMT]]></title><description><![CDATA[<p>std::auto_ptr solltest du nicht als Parameter von Containerklassen benutzen. Verwende besser einen shared_ptr o.ä. (s.a. <a href="http://en.wikipedia.org/wiki/Auto_ptr" rel="nofollow">http://en.wikipedia.org/wiki/Auto_ptr</a> )</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1933075</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1933075</guid><dc:creator><![CDATA[Th69]]></dc:creator><pubDate>Wed, 28 Jul 2010 12:10:59 GMT</pubDate></item></channel></rss>