The combine function been bug since yesterday.

Been trying everything back then, define in the source file, remove some code to prevent overlapping definition, etc...
I don't know what I should do, can anyone help on this?

#ifndef SALES_DATA
#define SALES_DATA

#include <iostream>

struct Sales_data {
    // new members: operations on Sales_data objects
    std::string isbn() const { return bookNo; }
    double avg_price() const;
    Sales_data& combine(const Sales_data&);

    // data members are unchanged from
    std::string bookNo;
    unsigned units_sold;
    double revenue;
};

Sales_data& Sales_data::combine(const Sales_data &rhs)
{
    units_sold += rhs.units_sold;
    revenue += rhs.revenue;
    return *this;
}

std::istream &read(std::istream & is, Sales_data &item);
std::ostream &print(std::ostream &os, const Sales_data & item);
Sales_data add(const Sales_data &lhs, const Sales_data &rhs);

#endif

what compiler and operating systems are you using? And post a few of the errors.

Why don't you just call it a class instead of struct because that's what it is. structs are carry-over from C language and normally do not contain methods. Although both structs and classes are nearly the same in C++ it is more conventional to call it a class when it contains methods.

Edited 3 Years Ago by Ancient Dragon

mingW and windows 7 ultimate 64bit

this is the error:
Click Here

This is the exercise coming from C++ primer 5th edi.
not learned about class yet.

Edited 3 Years Ago by Vasthor: ehem

This article has been dead for over six months. Start a new discussion instead.