I've been trying to fix these errors for a while now and I'm having difficulty. Can anyone help? I've attached my header file, .cpp file and main.

The C2533 and C2511 are both in my .cpp file.

c:\documents and settings\tina\my documents\visual studio 2008\projects\csci112lab4\csci112lab4\invoice.cpp(15) : error C2533: 'Invoice::{ctor}' : constructors not allowed a return type
c:\documents and settings\tina\my documents\visual studio 2008\projects\csci112lab4\csci112lab4\invoice.cpp(113) : error C2511: 'void Invoice::print(Invoice)' : overloaded member function not found in 'Invoice'
        c:\documents and settings\tina\my documents\visual studio 2008\projects\csci112lab4\csci112lab4\invoice.h(11) : see declaration of 'Invoice'

The C 2144 error is in my main.

c:\documents and settings\tina\my documents\visual studio 2008\projects\csci112lab4\csci112lab4\main.cpp(15) : error C2144: syntax error : 'int' should be preceded by ';'

The problem is at the last line of invoice.h -- a semicolon is required at the end of a class declaration.

Thanks so much!

That solves two errors, but the C2511 is still there.

The error is as follows:

c:\documents and settings\tina\my documents\visual studio 2008\projects\csci112lab4\csci112lab4\invoice.cpp(113) : error C2511: 'void Invoice::print(Invoice)' : overloaded member function not found in 'Invoice'
c:\documents and settings\tina\my documents\visual studio 2008\projects\csci112lab4\csci112lab4\invoice.h(11) : see declaration of 'Invoice'

My program code is attached. Please help. This assignment is due at midnight and I can't get the bloody thing to even compile so that I can start debugging.

It involves this line:

void Invoice::print(Invoice *bill)
{			//print values in current bill

Which comes from:

class Invoice
{	
...

void print(Invoice *) const;

Thanks!

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

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.

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

This just gives me more errors.

c:\documents and settings\tina\my documents\visual studio 2008\projects\csci112lab4\csci112lab4\invoice.cpp(121) : error C2039: 'getShippingCost' : is not a member of 'Invoice'
c:\documents and settings\tina\my documents\visual studio 2008\projects\csci112lab4\csci112lab4\invoice.h(14) : see declaration of 'Invoice'
Generating Code...
Compiling...
main.cpp
c:\documents and settings\tina\my documents\visual studio 2008\projects\csci112lab4\csci112lab4\main.cpp(65) : error C2664: 'Invoice::print' : cannot convert parameter 1 from 'Invoice *' to 'Invoice'
No constructor could take the source type, or constructor overload resolution was ambiguous

Ok, now I'm down to one error in main.

c:\documents and settings\tina\my documents\visual studio 2008\projects\csci112lab4\csci112lab4\main.cpp(65) : error C2664: 'Invoice::print' : cannot convert parameter 1 from 'Invoice *' to 'Invoice'
No constructor could take the source type, or constructor overload resolution was ambiguous

for the line:

bill[place].print(bill);

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.

Ok, now I'm down to one error in main.

c:\documents and settings\tina\my documents\visual studio 2008\projects\csci112lab4\csci112lab4\main.cpp(65) : error C2664: 'Invoice::print' : cannot convert parameter 1 from 'Invoice *' to 'Invoice'
No constructor could take the source type, or constructor overload resolution was ambiguous

for the line:

bill[place].print(bill);

>>'getShippingCost' is not a member of 'Invoice'

Yes -- you didn't see the code I posted earlier?

I have tried changing them. it backfires every time. is there any way I could supply an explicit conversion?

Don't create two threads about the same problem. I merged your two threads and don't intend to do it again!

oh. sorry. I'm just really trying to get this done in time. I had 5 due tonight (with only 1 1/2 weeks to do them) and I only have 3 completely finished. The last one isn't getting done because I don't have time to type the code up and then compile it and debug. So I need this one to be as good as it can...

sorry about that...

>>
Yes -- you didn't see the code I posted earlier?

Is this in response to supplying an explicit conversion? Because if so, I'm still doing something else wrong because i have the same thing in the code box you provided.

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)

Thanks for replying and all the help you've given me thus far!

Well, when I do that I get 9 occurrences of the same error - one per line.

c:\documents and settings\tina\my documents\visual studio 2008\projects\csci112lab4\csci112lab4\invoice.cpp(114) : error C2662: 'Invoice::getInvoiceNum' : cannot convert 'this' pointer from 'const Invoice' to 'Invoice &'
Conversion loses qualifiers

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.

Ok, fixed that one. That was my fault for not checking my code exactly. I left const in the .h file.

But...now I'm back to that blasted C2511 error.

c:\documents and settings\tina\my documents\visual studio 2008\projects\csci112lab4\csci112lab4\invoice.cpp(113) : error C2511: 'void Invoice::print(void) const' : overloaded member function not found in 'Invoice'
c:\documents and settings\tina\my documents\visual studio 2008\projects\csci112lab4\csci112lab4\invoice.h(14) : see declaration of 'Invoice'

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()?

Read what I posted -- everything ... carefully.

Hey... it works...

stupid const. it didn't save when I built it again... sheesh.

Thanks so much for all of your help!!!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.