The problem is at the last line of invoice.h -- a semicolon is required at the end of a class declaration.
Ancient Dragon
Retired & Loving It
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
Several problems
1) add the const keyword
2) need to add () to function method calls
void Invoice::print(Invoice bill) const
{ //print values in current bill
cout<<"Invoice Number: "<<bill.getInvoiceNum()<<endl<<endl;
cout<<"Part Number: "<<bill.getPartNum()<<endl;
cout<<"Part Description: "<<bill.getPartDesc()<<endl;
cout<<"Quantity Shipped: "<<bill.getQuantityShip()<<endl;
cout<<"Unit Price ($/item): "<<bill.getUnitPrice()<<endl;
cout<<"Sales Tax Rate: "<<bill.getSalesTaxRate()<<endl;
cout<<"Sales Tax Amount: "<<bill.calcSalesTaxAm()<<endl;
cout<<"Shipping Cost: "<<bill.getShipCost()<<endl;
cout<<"Total Cost: "<<bill.calcTotCost()<<endl;
}
Ancient Dragon
Retired & Loving It
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
In Invoice.h you declare this function:
void print(Invoice) const;
However, I don't think you can use Invoice as a parameter to a class member funtion in the Invoice class delaration because the class hasn't been fully declared yet. You can have a pointer to class type in the class declaration, though. For your purposes I don't think you want either. I'd declare print() to have a void parameter list. It would be used to print() the Invoice invoking it. That is:
Invoice i;
i.print();
will print the Invoice object called i.
But then again, I've been wrong before.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
look at the parameter in the .h file -- it is a pointer. Now look at the parameter in the line you quoted -- that is NOT a pointer. They have to be consistent, one of the two has to be changed.
Ancient Dragon
Retired & Loving It
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
>>'getShippingCost' is not a member of 'Invoice'
Yes -- you didn't see the code I posted earlier?
Ancient Dragon
Retired & Loving It
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
Don't create two threads about the same problem. I merged your two threads and don't intend to do it again!
Ancient Dragon
Retired & Loving It
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
The print() method doesn't need a parameter at all.
This time read all the code and correct the spelling as I did.
Invoice.cpp
void Invoice::print()
{ //print values in current bill
cout<<"Invoice Number: "<<getInvoiceNum()<<endl<<endl;
cout<<"Part Number: "<<getPartNum()<<endl;
cout<<"Part Description: "<<getPartDesc()<<endl;
cout<<"Quantity Shipped: "<<getQuantityShip()<<endl;
cout<<"Unit Price ($/item): "<<getUnitPrice()<<endl;
cout<<"Sales Tax Rate: "<<getSalesTaxRate()<<endl;
cout<<"Sales Tax Amount: "<<calcSalesTaxAm()<<endl;
cout<<"Shipping Cost: "<<getShipCost()<<endl;
cout<<"Total Cost: "<<calcTotCost()<<endl;
}
invoice.h
void print();
main.cpp
if (bill[place].getInvoiceNum() == inum)
Ancient Dragon
Retired & Loving It
30,043 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,341
in main you call print() on an Invoice object just like you call getInvoiceNum() or one of the other plublic methods.
bill[place].print();
assuming you've changed the print() method to have a void parameter list.
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396
Did you update the declaration of print() in the .h file and the definition of print() in the .cpp file to correspond with the new signature of print()?
Lerner
Nearly a Posting Maven
2,382 posts since Jul 2005
Reputation Points: 739
Solved Threads: 396