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);

3 Years
Discussion Span
Last Post by Schol-R-LEA

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 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 by Vasthor: ehem


This posting may help explain why it is (generally speaking) a mistake to include functions in a header, and what headers are mainly used for in the first place.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.