2017-09-16 16 views
-4
#ifndef SALESITEM_H 
#define SALESITEM_H 
#include <iostream> 
#include <string> 
using namespace std; 
class Sales_data 
{ 
public: 
    Sales_data(unsigned num,int pr , string isb):units_sold(num),price(pr),isbn(isb) 
{ 
    cout<<"it works"<<endl; 
}; 
    Sales_data() = default; 
    Sales_data& combine(const Sales_data& rhs); 

    string Getisbn() ; 
    int Getprice() ; 
    unsigned Getunits_sold(); 


private: 
    unsigned units_sold; 
    int price; 
    string isbn; 
}; 
Sales_data& Sales_data::combine(const Sales_data& rhs) 
{ 
    units_sold += rhs.units_sold; 
    price += rhs.price; 
    return *this; 
} 
string Sales_data::Getisbn() 
{ 
    return isbn; 
} 
int Sales_data::Getprice() 
{ 
    return units_sold; 
} 
unsigned Sales_data::Getunits_sold() 
{ 
    return units_sold; 
} 
istream& read(istream& in,Sales_data &book) 
{ 
    in >>book.Getisbn(); 
    return in; 
} 

そして、それは>> book.Getunits_sold() /Users/apple/Desktop/shirley/shirley/Sales_item.h:185でログ無効なオペランド:

でその問題を示し、それはと言う理由を私は知らないバイナリ表現( 'はistream'(別名 'basic_istream') と '文字列'(別名 'のbasic_string、 アロケータ>'))

+0

あなたのインクルードが表示されるように完全な例を投稿してください。私は '#include 'がそれらの一つではないと思うでしょう。 –

+0

#include がヘッダにあります –

+1

あなたの例では '>>'があり、右側に文字列がありません。あなたの例には185行もありませんので、私はあなたが表示されていないコードにエラーがあると言います。あなたが 'book.Getunits_sold();'で何を考えているのかは分かりません。 –

答えて

0

への無効 オペランド::8無効なオペラートがありますrをバイナリ式(floatとfloat)に変換します。どうもありがとうございました!

int main(int argc, char** argv) { 

    float a; 
    float b; 

    b = a - (int) a; 

    printf("Write a number:"); 
    scanf("%f", &a); 

    if ((b == 0)&&(b % 2 == 0)) { 
     printf("It is an integer even number"); 
    } else if ((b == 0)&&(b % 2 != 0)) { 
     printf("It is an integer odd number"); 
    } else { 
     printf("It is a real number"); 
    } 

    return (EXIT_SUCCESS); 
} 
+0

これは質問に対する答えを提供しません。十分な[評判](https://stackoverflow.com/help/whats-reputation)があれば、[投稿にコメントする]ことができます(https://stackoverflow.com/help/privileges/comment)。代わりに、[質問者からの明確化を必要としない回答を提供する](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-c​​an- i-do-代わりに)。 - [レビューから](/レビュー/低品質の投稿/ 17666331) – purplepsycho

関連する問題