<?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[Object in Vector geschoben und push_back will nicht so wie ich.]]></title><description><![CDATA[<p>Ich hätte es gerne dass das hier funktioniert.</p>
<pre><code>device.push_back(i,s);
device.push_back(22,&quot;Lumia&quot;);
</code></pre>
<p>Die Konstruktoren sind gegeben und ich such schon seit Stunden diesen blöden Fehler <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>main.cpp</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;string&gt;
#include &quot;handy.h&quot;
using namespace std;

int main()
{
    vector &lt;Handy&gt; device;

    string s = &quot;ss&quot;;
    size_t i = 3;

    // Nur so gelingt mir der Mist bis jetzt
    device.push_back(Handy(i,s));

    for(size_t i=0; i&lt;device.size();i++){
        cout &lt;&lt; device[i].get_name();
    }

    return 0;
}
</code></pre>
<p>handy.h</p>
<pre><code>#ifndef HANDY_H_INCLUDED
#define HANDY_H_INCLUDED
#include &lt;string&gt;

using namespace std;

class Handy{
private:
    size_t preis;
    string name;
public:
    Handy();
    Handy(size_t &amp;p,string &amp;n);
    Handy(size_t &amp;p);
    Handy(string &amp;n);
    ~Handy();

    size_t get_preis() const {return preis;};
    string get_name() const {return name;};

    void write_preis();
    void write_name();

    void setzte_preis(size_t &amp;p);
    void setzte_name(string &amp;n);

};

#endif // HANDY_H_INCLUDED
</code></pre>
<p>handy.cpp</p>
<pre><code>#include &quot;handy.h&quot;
#include &lt;string&gt;
#include &lt;iostream&gt;
using namespace std;

Handy::Handy(){
    preis=0;
    name=&quot;i&quot;;
}

Handy::Handy(size_t &amp;p,string &amp;n){
    preis = p;
    name = n;
}

Handy::Handy(size_t &amp;p){
    preis = p;
    name = &quot;&quot;;
}

Handy::Handy(string &amp;n){
    name = n;
    preis = 0;
}

Handy::~Handy(){
}

void Handy::write_preis(){
   // getline(cin,preis);
   cin &gt;&gt; preis;
}

void Handy::write_name(){
    getline(cin,name);
}

void Handy::setzte_preis(size_t &amp;p){
    preis = p;
}
void Handy::setzte_name(string &amp;n){
    name = n;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/322634/object-in-vector-geschoben-und-push_back-will-nicht-so-wie-ich</link><generator>RSS for Node</generator><lastBuildDate>Fri, 17 Jul 2026 01:50:35 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/322634.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 01 Jan 2014 20:10:14 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Object in Vector geschoben und push_back will nicht so wie ich. on Wed, 01 Jan 2014 20:10:14 GMT]]></title><description><![CDATA[<p>Ich hätte es gerne dass das hier funktioniert.</p>
<pre><code>device.push_back(i,s);
device.push_back(22,&quot;Lumia&quot;);
</code></pre>
<p>Die Konstruktoren sind gegeben und ich such schon seit Stunden diesen blöden Fehler <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f644.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--face_with_rolling_eyes"
      title=":rolling_eyes:"
      alt="🙄"
    /></p>
<p>main.cpp</p>
<pre><code>#include &lt;iostream&gt;
#include &lt;vector&gt;
#include &lt;string&gt;
#include &quot;handy.h&quot;
using namespace std;

int main()
{
    vector &lt;Handy&gt; device;

    string s = &quot;ss&quot;;
    size_t i = 3;

    // Nur so gelingt mir der Mist bis jetzt
    device.push_back(Handy(i,s));

    for(size_t i=0; i&lt;device.size();i++){
        cout &lt;&lt; device[i].get_name();
    }

    return 0;
}
</code></pre>
<p>handy.h</p>
<pre><code>#ifndef HANDY_H_INCLUDED
#define HANDY_H_INCLUDED
#include &lt;string&gt;

using namespace std;

class Handy{
private:
    size_t preis;
    string name;
public:
    Handy();
    Handy(size_t &amp;p,string &amp;n);
    Handy(size_t &amp;p);
    Handy(string &amp;n);
    ~Handy();

    size_t get_preis() const {return preis;};
    string get_name() const {return name;};

    void write_preis();
    void write_name();

    void setzte_preis(size_t &amp;p);
    void setzte_name(string &amp;n);

};

#endif // HANDY_H_INCLUDED
</code></pre>
<p>handy.cpp</p>
<pre><code>#include &quot;handy.h&quot;
#include &lt;string&gt;
#include &lt;iostream&gt;
using namespace std;

Handy::Handy(){
    preis=0;
    name=&quot;i&quot;;
}

Handy::Handy(size_t &amp;p,string &amp;n){
    preis = p;
    name = n;
}

Handy::Handy(size_t &amp;p){
    preis = p;
    name = &quot;&quot;;
}

Handy::Handy(string &amp;n){
    name = n;
    preis = 0;
}

Handy::~Handy(){
}

void Handy::write_preis(){
   // getline(cin,preis);
   cin &gt;&gt; preis;
}

void Handy::write_name(){
    getline(cin,name);
}

void Handy::setzte_preis(size_t &amp;p){
    preis = p;
}
void Handy::setzte_name(string &amp;n){
    name = n;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2374473</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2374473</guid><dc:creator><![CDATA[Plattfuss]]></dc:creator><pubDate>Wed, 01 Jan 2014 20:10:14 GMT</pubDate></item><item><title><![CDATA[Reply to Object in Vector geschoben und push_back will nicht so wie ich. on Wed, 01 Jan 2014 20:12:19 GMT]]></title><description><![CDATA[<p>Wenn du gesagt hättest, was der blöde Fehler ist ...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2374474</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2374474</guid><dc:creator><![CDATA[manni66]]></dc:creator><pubDate>Wed, 01 Jan 2014 20:12:19 GMT</pubDate></item><item><title><![CDATA[Reply to Object in Vector geschoben und push_back will nicht so wie ich. on Wed, 01 Jan 2014 20:13:20 GMT]]></title><description><![CDATA[<p><a href="http://en.cppreference.com/w/cpp/container/vector/emplace_back" rel="nofollow">Suchst Du das hier?</a></p>
]]></description><link>https://www.c-plusplus.net/forum/post/2374475</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2374475</guid><dc:creator><![CDATA[Caligulaminus]]></dc:creator><pubDate>Wed, 01 Jan 2014 20:13:20 GMT</pubDate></item><item><title><![CDATA[Reply to Object in Vector geschoben und push_back will nicht so wie ich. on Wed, 01 Jan 2014 20:13:28 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">device.push_back(i,s);
</code></pre>
<p>Entweder</p>
<pre><code class="language-cpp">device.push_back(Handy(i,s));
</code></pre>
<p>oder</p>
<pre><code class="language-cpp">[cpp]device.emplace_back(i,s);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/2374476</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2374476</guid><dc:creator><![CDATA[emplac0r]]></dc:creator><pubDate>Wed, 01 Jan 2014 20:13:28 GMT</pubDate></item><item><title><![CDATA[Reply to Object in Vector geschoben und push_back will nicht so wie ich. on Wed, 01 Jan 2014 20:39:29 GMT]]></title><description><![CDATA[<p>Der Fehler ist.</p>
<blockquote>
<p>Fehler: keine passende Funktion für Aufruf von</p>
<p>/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/main.cpp|15|Fehler: keine passende Funktion für Aufruf von »std::vector&lt;Handy&gt;::push_back(int, const char [2])«|<br />
/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/main.cpp|15|Anmerkung: Kandidat ist:|<br />
/usr/include/c++/4.8.2/bits/stl_vector.h|901|Anmerkung: void std::vector&lt;_Tp, _Alloc&gt;::push_back(const value_type&amp;) [with _Tp = Handy; _Alloc = std::allocator&lt;Handy&gt;; std::vector&lt;_Tp, _Alloc&gt;::value_type = Handy]|<br />
/usr/include/c++/4.8.2/bits/stl_vector.h|901|Anmerkung: Kandidat erwartet 1 Argument, 2 angegeben|<br />
/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/main.cpp|12|Warnung: Variable »i« wird nicht verwendet [-Wunused-variable]|<br />
||=== Build finished: 5 errors, 0 warnings (0 minutes, 0 seconds) ===|</p>
</blockquote>
]]></description><link>https://www.c-plusplus.net/forum/post/2374479</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2374479</guid><dc:creator><![CDATA[Plattfuss]]></dc:creator><pubDate>Wed, 01 Jan 2014 20:39:29 GMT</pubDate></item><item><title><![CDATA[Reply to Object in Vector geschoben und push_back will nicht so wie ich. on Wed, 01 Jan 2014 20:49:13 GMT]]></title><description><![CDATA[<p>Die Lösung hast du doch oben schon gepostet bekommen. Eben emplace_back (in C++11).</p>
<p>Zweitens gibt es solche Seiten wie <a href="http://www.cplusplus.com/reference/" rel="nofollow">http://www.cplusplus.com/reference/</a>([<a href="http://www.cplusplus.com/reference/vector/vector/push_back/" rel="nofollow">1</a>] bzw. [<a href="http://www.cplusplus.com/reference/vector/vector/emplace_back/" rel="nofollow">2</a>]) oder <a href="http://en.cppreference.com/w/" rel="nofollow">http://en.cppreference.com/w/</a> ([<a href="http://en.cppreference.com/w/cpp/container/vector/push_back" rel="nofollow">3</a>] bzw. [<a href="http://en.cppreference.com/w/cpp/container/vector/emplace_back" rel="nofollow">4</a>]), wo das auch alles erklärt ist. Als Programmierer ist bzw. sollte man dauernd auf solchen Seiten unterwegs sein!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2374482</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2374482</guid><dc:creator><![CDATA[Skym0sh0]]></dc:creator><pubDate>Wed, 01 Jan 2014 20:49:13 GMT</pubDate></item><item><title><![CDATA[Reply to Object in Vector geschoben und push_back will nicht so wie ich. on Wed, 01 Jan 2014 21:12:21 GMT]]></title><description><![CDATA[<p>emplace funktioniert auch nicht <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
<p>/usr/include/c++/4.8.2/bits/alloc_traits.h|254| erfordert durch »static typename std::enable_if&lt;std::allocator_traits&lt;_Alloc&gt;::__construct_helper&lt;_Tp, _Args&gt;::value, void&gt;::type std::allocator_traits&lt;_Alloc&gt;::_S_construct(_Alloc&amp;, _Tp*, _Args&amp;&amp; ...) [with _Tp = Handy; _Args = {int, const char (&amp;)[3]}; _Alloc = std::allocator&lt;Handy&gt;; typename std::enable_if&lt;std::allocator_traits&lt;_Alloc&gt;::__construct_helper&lt;_Tp, _Args&gt;::value, void&gt;::type = void]«|<br />
/usr/include/c++/4.8.2/bits/alloc_traits.h|393| erfordert durch »static decltype (_S_construct(__a, __p, (forward&lt;_Args&gt;)(std::allocator_traits::construct::__args)...)) std::allocator_traits&lt;_Alloc&gt;::construct(_Alloc&amp;, _Tp*, _Args&amp;&amp; ...) [with _Tp = Handy; _Args = {int, const char (&amp;)[3]}; _Alloc = std::allocator&lt;Handy&gt;; decltype (_S_construct(__a, __p, (forward&lt;_Args&gt;)(std::allocator_traits::construct::__args)...)) = &lt;type error&gt;]«|<br />
/usr/include/c++/4.8.2/bits/vector.tcc|97| erfordert durch »void std::vector&lt;_Tp, _Alloc&gt;::emplace_back(_Args&amp;&amp; ...) [with _Args = {int, const char (&amp;)[3]}; _Tp = Handy; _Alloc = std::allocator&lt;Handy&gt;]«|<br />
/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/main.cpp|14| von hier erfordert|<br />
/usr/include/c++/4.8.2/ext/new_allocator.h|120|Fehler: keine passende Funktion für Aufruf von »Handy::Handy(int, const char [3])«|<br />
/usr/include/c++/4.8.2/ext/new_allocator.h|120|Anmerkung: Kandidaten sind:|<br />
/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/handy.h|15|Anmerkung: Handy::Handy(std::string&amp;)|<br />
/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/handy.h|15|Anmerkung: Kandidat erwartet 1 Argument, 2 angegeben|<br />
/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/handy.h|14|Anmerkung: Handy::Handy(size_t&amp;)|<br />
/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/handy.h|14|Anmerkung: Kandidat erwartet 1 Argument, 2 angegeben|<br />
/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/handy.h|13|Anmerkung: Handy::Handy(size_t&amp;, std::string&amp;)|<br />
/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/handy.h|13|Anmerkung: keine bekannte Umwandlung für Argument 1 von »int« nach »size_t&amp; {aka long unsigned int&amp;}«|<br />
/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/handy.h|12|Anmerkung: Handy::Handy()|<br />
/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/handy.h|12|Anmerkung: Kandidat erwartet 0 Argumente, 2 angegeben|<br />
/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/handy.h|7|Anmerkung: Handy::Handy(const Handy&amp;)|<br />
/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/handy.h|7|Anmerkung: Kandidat erwartet 1 Argument, 2 angegeben|<br />
||=== Build finished: 16 errors, 0 warnings (0 minutes, 0 seconds) ===|</p>
<p>usw. die fehler wollt ihr gar nicht alle sehen xD<br />
ich schau mir mal einfach die Links an.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2374488</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2374488</guid><dc:creator><![CDATA[Plattfuss]]></dc:creator><pubDate>Wed, 01 Jan 2014 21:12:21 GMT</pubDate></item><item><title><![CDATA[Reply to Object in Vector geschoben und push_back will nicht so wie ich. on Wed, 01 Jan 2014 21:14:05 GMT]]></title><description><![CDATA[<p>Dein Handykonstruktor erwartet eine Referenz auf einen size_t, da kannst du kein Literal nehmen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2374490</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2374490</guid><dc:creator><![CDATA[Nathan]]></dc:creator><pubDate>Wed, 01 Jan 2014 21:14:05 GMT</pubDate></item><item><title><![CDATA[Reply to Object in Vector geschoben und push_back will nicht so wie ich. on Wed, 01 Jan 2014 21:23:36 GMT]]></title><description><![CDATA[<p>Ich tippe auf</p>
<p>Plattfuss' Compiler schrieb:</p>
<blockquote>
<p>/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/handy.h|13|Anmerkung: Handy::Handy(<strong>size_t&amp;</strong>, std::string&amp;)|<br />
/home/cseipel/Code::Blocks Kram/GTK/test project/KlassenINVektoren/handy.h|13|Anmerkung: <strong>keine bekannte Umwandlung für Argument 1 von »int« nach »size_t&amp;</strong> {aka long unsigned int&amp;}«|</p>
</blockquote>
<p>Edit: zu spät...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2374494</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2374494</guid><dc:creator><![CDATA[Caligulaminus]]></dc:creator><pubDate>Wed, 01 Jan 2014 21:23:36 GMT</pubDate></item></channel></rss>