2017-09-16 1 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 : 8 :이 있다고 왜 바이너리 표현 ('IStream을'(일명 'basic_istream보다는') 와 '캐릭터'(일명 'basic_string, 할당>'))에 잘못된 피연산자

+0

귀하의 포함 사항을 볼 수 있도록 전체 예제를 게시하십시오. 나는'#include '이 그들 중 하나가 아니라고 추측 할 것이다. –

+0

#include 이 헤더에 있습니다. –

+1

글쎄, 예제에는'>>'가 하나 있는데, 오른쪽에는 문자열이 없습니다. 당신의 예제에는 185 행도 없으므로, 나는 여러분이 보여주지 않은 코드에 오류가 있다고 말할 것입니다. 당신이'book.Getunits_sold();'에서 무엇을 생각할 지 모르겠습니다. –

답변

0

나도 몰라 잘못된 operato가 있습니다. 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-can- i-do- 대신). - [리뷰에서] (리뷰/저품절 포스트/17666331) – purplepsycho

관련 문제