#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;
}
它表示日志中的问题
在&GT;&GT; book.Getunits_sold() /Users/apple/Desktop/shirley/shirley/Sales_item.h:185:8:无效 操作数到二进制表达式(&#39; istream&#39;(又名&#39; basic_istream&#39;) 和&#39;字符串&#39; (又名&#39; basic_string, 分配器&gt;&#39;))
答案 0 :(得分:0)
我不知道为什么它说二元表达式(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);
}