| | |
Need help solving errors: C2533, C2511, C2144.
![]() |
•
•
Join Date: Dec 2008
Posts: 20
Reputation:
Solved Threads: 0
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 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 ';'
•
•
Join Date: Dec 2008
Posts: 20
Reputation:
Solved Threads: 0
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:
Which comes from:
Thanks!
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:
C++ Syntax (Toggle Plain Text)
void Invoice::print(Invoice *bill) { //print values in current bill
Which comes from:
C++ Syntax (Toggle Plain Text)
class Invoice { ... void print(Invoice *) const;
Thanks!
Several problems
1) add the const keyword
2) need to add () to function method calls
1) add the const keyword
2) need to add () to function method calls
C++ Syntax (Toggle Plain Text)
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; }
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
•
•
Join Date: Jul 2005
Posts: 1,671
Reputation:
Solved Threads: 261
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.
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.
Last edited by Lerner; Dec 4th, 2008 at 11:40 pm.
Klatu Barada Nikto
•
•
Join Date: Dec 2008
Posts: 20
Reputation:
Solved Threads: 0
•
•
•
•
Several problems
1) add the const keyword
2) need to add () to function method calls
C++ Syntax (Toggle Plain Text)
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; }
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
•
•
Join Date: Dec 2008
Posts: 20
Reputation:
Solved Threads: 0
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:
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:
C++ Syntax (Toggle Plain Text)
bill[place].print(bill);
•
•
Join Date: Dec 2008
Posts: 20
Reputation:
Solved Threads: 0
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:
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:
C++ Syntax (Toggle Plain Text)
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.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
![]() |
Other Threads in the C++ Forum
- Previous Thread: C++ graphics
- Next Thread: Inheritance, and code not running
| Thread Tools | Search this Thread |
action api array auto based beginner binary bitmap c++ c/c++ calculator challenge char class classes code coding compile console conversion count createcopyofanyfileinc delete deploy desktop developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game garbage givemetehcodez graph gui hmenu homeworkhelp homeworkhelper iamthwee ifstream input insert int integer java lib linkedlist linker loop looping loops map math matrix memory multiple news node noob output parameter pointer primenumbersinrange problem program programming project python random read recursion reference rpg sockets string strings temperature template test text text-file tree url variable vector video win32 windows winsock wordfrequency wxwidgets






