<?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[Primmer 5th Edition Probleme]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich hab angefangen den Primer durch zu arbeiten ich hab aber ein Problem.</p>
<p>Ich soll ne Header Datei aus dem Internet benutzen. Hab auch alles soweit hinbekommen ich bekomm aber ne Fehlermeldung.</p>
<pre><code>#include &lt;iostream&gt;
#include &quot;Sales_item.h&quot;

int main()
{
    Sales_item item1, item2;

    std:: cin &gt;&gt; item1 &gt;&gt; item2;

    if(item1.isbn() == item2.isbn()){
        std::cout &lt;&lt; item1 + item2 &lt;&lt; std::endl;
        return 0}

    else {
        std::cerr &lt;&lt; &quot;ISBN-Nummern stimmen nicht überein!&quot; &lt;&lt; std::endl;
        return -1;
    }

}
</code></pre>
<p>Das is der code steht auch genau so im buch.</p>
<p>Hier is die Header Datei</p>
<pre><code>/*
 * This file contains code from &quot;C++ Primer, Fourth Edition&quot;, by Stanley B.
 * Lippman, Jose Lajoie, and Barbara E. Moo, and is covered under the
 * copyright and warranty notices given in that book:
 * 
 * &quot;Copyright (c) 2005 by Objectwrite, Inc., Jose Lajoie, and Barbara E. Moo.&quot;
 * 
 * 
 * &quot;The authors and publisher have taken care in the preparation of this book,
 * but make no expressed or implied warranty of any kind and assume no
 * responsibility for errors or omissions. No liability is assumed for
 * incidental or consequential damages in connection with or arising out of the
 * use of the information or programs contained herein.&quot;
 * 
 * Permission is granted for this code to be used for educational purposes in
 * association with the book, given proper citation if and when posted or
 * reproduced.Any commercial use of this code requires the explicit written
 * permission of the publisher, Addison-Wesley Professional, a division of
 * Pearson Education, Inc. Send your request for permission, stating clearly
 * what code you would like to use, and in what specific way, to the following
 * address: 
 * 
 * 	Pearson Education, Inc.
 * 	Rights and Contracts Department
 * 	75 Arlington Street, Suite 300
 * 	Boston, MA 02216
 * 	Fax: (617) 848-7047
*/ 

#ifndef SALESITEM_H
#define SALESITEM_H

// Definition of Sales_item class and related functions goes here

// NB: when prepare this file for the code directory on the web,
//     be sure all operations are defined as inlines within the
//     header so that user code can use the operations without
//     needing to compile and use a corresponding .cc file

#include &lt;iostream&gt;
#include &lt;string&gt;

class Sales_item {
    friend bool operator==(const Sales_item&amp;, const Sales_item&amp;);
    friend std::istream&amp; operator&gt;&gt;(std::istream&amp;, Sales_item&amp;);
    friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp;, const Sales_item&amp;);
// other members as before
public:
    // added constructors to initialize from a string or an istream
    Sales_item(const std::string &amp;book):
              isbn(book), units_sold(0), revenue(0.0) { }
    Sales_item(std::istream &amp;is) { is &gt;&gt; *this; }
public:
    // operations on Sales_item objects
    // member binary operator: left-hand operand bound to implicit this pointer
    Sales_item&amp; operator+=(const Sales_item&amp;);
    // other members as before

public:
    // operations on Sales_item objects
    double avg_price() const;
    bool same_isbn(const Sales_item &amp;rhs) const
        { return isbn == rhs.isbn; }
    // default constructor needed to initialize members of built-in type
    Sales_item(): units_sold(0), revenue(0.0) { }
// private members as before
private:
    std::string isbn;
    unsigned units_sold;
    double revenue;

};

// nonmember binary operator: must declare a parameter for each operand
Sales_item operator+(const Sales_item&amp;, const Sales_item&amp;);

inline bool 
operator==(const Sales_item &amp;lhs, const Sales_item &amp;rhs)
{
    return lhs.units_sold == rhs.units_sold &amp;&amp;
           lhs.revenue == rhs.revenue &amp;&amp;
	   lhs.same_isbn(rhs);
}

inline bool 
operator!=(const Sales_item &amp;lhs, const Sales_item &amp;rhs)
{
    return !(lhs == rhs); // != defined in terms of operator==
}

#endif
</code></pre>
<p>Und hier die Fehlermeldung</p>
<p>g++.exe -Wall -fexceptions -g -std=c++11 -c H:\projekte\Sales\main.cpp -o obj\Debug\main.o<br />
In file included from H:\projekte\Sales\main.cpp:2:0:<br />
h:\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/Sales_item.h: In function 'int main()':<br />
h:\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/Sales_item.h:68:17: error: 'std::string Sales_item::isbn' is private<br />
H:\projekte\Sales\main.cpp:13:14: error: within this context<br />
H:\projekte\Sales\main.cpp:13:19: error: no match for call to '(std::string {aka std::basic_string&lt;char&gt;}) ()'<br />
In file included from H:\projekte\Sales\main.cpp:2:0:<br />
h:\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/Sales_item.h:68:17: error: 'std::string Sales_item::isbn' is private<br />
H:\projekte\Sales\main.cpp:13:30: error: within this context<br />
H:\projekte\Sales\main.cpp:13:35: error: no match for call to '(std::string {aka std::basic_string&lt;char&gt;}) ()'<br />
H:\projekte\Sales\main.cpp:15:17: error: expected ';' before '}' token<br />
Process terminated with status 1 (0 minutes, 2 seconds)<br />
7 errors, 0 warnings (0 minutes, 2 seconds)</p>
<p>Also ich glaub es liegt daran das ISBN Private is aber keine Ahnung was ich machen soll. hab alles so gemacht wies im buch steht. hat jemand nen rat?</p>
<p>beste grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/321657/primmer-5th-edition-probleme</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Jul 2026 06:04:43 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/321657.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 20 Nov 2013 12:38:19 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Primmer 5th Edition Probleme on Wed, 20 Nov 2013 12:38:19 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>Ich hab angefangen den Primer durch zu arbeiten ich hab aber ein Problem.</p>
<p>Ich soll ne Header Datei aus dem Internet benutzen. Hab auch alles soweit hinbekommen ich bekomm aber ne Fehlermeldung.</p>
<pre><code>#include &lt;iostream&gt;
#include &quot;Sales_item.h&quot;

int main()
{
    Sales_item item1, item2;

    std:: cin &gt;&gt; item1 &gt;&gt; item2;

    if(item1.isbn() == item2.isbn()){
        std::cout &lt;&lt; item1 + item2 &lt;&lt; std::endl;
        return 0}

    else {
        std::cerr &lt;&lt; &quot;ISBN-Nummern stimmen nicht überein!&quot; &lt;&lt; std::endl;
        return -1;
    }

}
</code></pre>
<p>Das is der code steht auch genau so im buch.</p>
<p>Hier is die Header Datei</p>
<pre><code>/*
 * This file contains code from &quot;C++ Primer, Fourth Edition&quot;, by Stanley B.
 * Lippman, Jose Lajoie, and Barbara E. Moo, and is covered under the
 * copyright and warranty notices given in that book:
 * 
 * &quot;Copyright (c) 2005 by Objectwrite, Inc., Jose Lajoie, and Barbara E. Moo.&quot;
 * 
 * 
 * &quot;The authors and publisher have taken care in the preparation of this book,
 * but make no expressed or implied warranty of any kind and assume no
 * responsibility for errors or omissions. No liability is assumed for
 * incidental or consequential damages in connection with or arising out of the
 * use of the information or programs contained herein.&quot;
 * 
 * Permission is granted for this code to be used for educational purposes in
 * association with the book, given proper citation if and when posted or
 * reproduced.Any commercial use of this code requires the explicit written
 * permission of the publisher, Addison-Wesley Professional, a division of
 * Pearson Education, Inc. Send your request for permission, stating clearly
 * what code you would like to use, and in what specific way, to the following
 * address: 
 * 
 * 	Pearson Education, Inc.
 * 	Rights and Contracts Department
 * 	75 Arlington Street, Suite 300
 * 	Boston, MA 02216
 * 	Fax: (617) 848-7047
*/ 

#ifndef SALESITEM_H
#define SALESITEM_H

// Definition of Sales_item class and related functions goes here

// NB: when prepare this file for the code directory on the web,
//     be sure all operations are defined as inlines within the
//     header so that user code can use the operations without
//     needing to compile and use a corresponding .cc file

#include &lt;iostream&gt;
#include &lt;string&gt;

class Sales_item {
    friend bool operator==(const Sales_item&amp;, const Sales_item&amp;);
    friend std::istream&amp; operator&gt;&gt;(std::istream&amp;, Sales_item&amp;);
    friend std::ostream&amp; operator&lt;&lt;(std::ostream&amp;, const Sales_item&amp;);
// other members as before
public:
    // added constructors to initialize from a string or an istream
    Sales_item(const std::string &amp;book):
              isbn(book), units_sold(0), revenue(0.0) { }
    Sales_item(std::istream &amp;is) { is &gt;&gt; *this; }
public:
    // operations on Sales_item objects
    // member binary operator: left-hand operand bound to implicit this pointer
    Sales_item&amp; operator+=(const Sales_item&amp;);
    // other members as before

public:
    // operations on Sales_item objects
    double avg_price() const;
    bool same_isbn(const Sales_item &amp;rhs) const
        { return isbn == rhs.isbn; }
    // default constructor needed to initialize members of built-in type
    Sales_item(): units_sold(0), revenue(0.0) { }
// private members as before
private:
    std::string isbn;
    unsigned units_sold;
    double revenue;

};

// nonmember binary operator: must declare a parameter for each operand
Sales_item operator+(const Sales_item&amp;, const Sales_item&amp;);

inline bool 
operator==(const Sales_item &amp;lhs, const Sales_item &amp;rhs)
{
    return lhs.units_sold == rhs.units_sold &amp;&amp;
           lhs.revenue == rhs.revenue &amp;&amp;
	   lhs.same_isbn(rhs);
}

inline bool 
operator!=(const Sales_item &amp;lhs, const Sales_item &amp;rhs)
{
    return !(lhs == rhs); // != defined in terms of operator==
}

#endif
</code></pre>
<p>Und hier die Fehlermeldung</p>
<p>g++.exe -Wall -fexceptions -g -std=c++11 -c H:\projekte\Sales\main.cpp -o obj\Debug\main.o<br />
In file included from H:\projekte\Sales\main.cpp:2:0:<br />
h:\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/Sales_item.h: In function 'int main()':<br />
h:\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/Sales_item.h:68:17: error: 'std::string Sales_item::isbn' is private<br />
H:\projekte\Sales\main.cpp:13:14: error: within this context<br />
H:\projekte\Sales\main.cpp:13:19: error: no match for call to '(std::string {aka std::basic_string&lt;char&gt;}) ()'<br />
In file included from H:\projekte\Sales\main.cpp:2:0:<br />
h:\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/../../../../include/Sales_item.h:68:17: error: 'std::string Sales_item::isbn' is private<br />
H:\projekte\Sales\main.cpp:13:30: error: within this context<br />
H:\projekte\Sales\main.cpp:13:35: error: no match for call to '(std::string {aka std::basic_string&lt;char&gt;}) ()'<br />
H:\projekte\Sales\main.cpp:15:17: error: expected ';' before '}' token<br />
Process terminated with status 1 (0 minutes, 2 seconds)<br />
7 errors, 0 warnings (0 minutes, 2 seconds)</p>
<p>Also ich glaub es liegt daran das ISBN Private is aber keine Ahnung was ich machen soll. hab alles so gemacht wies im buch steht. hat jemand nen rat?</p>
<p>beste grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2366524</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2366524</guid><dc:creator><![CDATA[PrimerNoob]]></dc:creator><pubDate>Wed, 20 Nov 2013 12:38:19 GMT</pubDate></item><item><title><![CDATA[Reply to Primmer 5th Edition Probleme on Wed, 20 Nov 2013 12:57:04 GMT]]></title><description><![CDATA[<p>Moin!</p>
<p>Falscher Download?<br />
Da steht ja <em>&quot;This file contains code from &quot;C++ Primer, Fourth Edition&quot;</em>.</p>
<p>Ich habe eben den Download für den gcc runtergeladen:<br />
<a href="http://www.informit.com/store/c-plus-plus-primer-9780321714114" rel="nofollow">http://www.informit.com/store/c-plus-plus-primer-9780321714114</a><br />
Und dort ist eine andere Sales_item.h drin. Nämlich für die fünfte Ausgabe.</p>
<p>Viel Erfolg.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2366530</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2366530</guid><dc:creator><![CDATA[Furble Wurble]]></dc:creator><pubDate>Wed, 20 Nov 2013 12:57:04 GMT</pubDate></item><item><title><![CDATA[Reply to Primmer 5th Edition Probleme on Wed, 20 Nov 2013 12:58:47 GMT]]></title><description><![CDATA[<p>Du hast vollkommen recht, es liegt daran, dass <code>isbn</code> private ist und du von aussen keinen Zugriff darauf hast. Andererseits bietet die Klasse <code>SalesItem</code> die Methode <code>same_isbn</code> an, die zwei SalesItems vergleicht. Die Korrekur deines Quelltextes sieht so aus, dass du</p>
<pre><code>...
if(item1.isbn() == item2.isbn())
...
</code></pre>
<p>durch</p>
<pre><code>...
if(item1.same_isbn( item2 ) )
...
</code></pre>
<p>ersetzt.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2366531</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2366531</guid><dc:creator><![CDATA[DocShoe]]></dc:creator><pubDate>Wed, 20 Nov 2013 12:58:47 GMT</pubDate></item><item><title><![CDATA[Reply to Primmer 5th Edition Probleme on Wed, 20 Nov 2013 13:28:14 GMT]]></title><description><![CDATA[<p>Danke Furble das war der Fehler <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>Danke auch an Doc</p>
<p>Grüße</p>
]]></description><link>https://www.c-plusplus.net/forum/post/2366538</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/2366538</guid><dc:creator><![CDATA[PrimerNoob]]></dc:creator><pubDate>Wed, 20 Nov 2013 13:28:14 GMT</pubDate></item></channel></rss>