943,752 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2776
  • C++ RSS
You are currently viewing page 1 of this multi-page discussion thread
Dec 4th, 2008
0

Need help solving errors: C2533, C2511, C2144.

Expand Post »
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 ';'
Attached Files
File Type: cpp Invoice.cpp (3.6 KB, 24 views)
File Type: h Invoice.h (1.3 KB, 27 views)
File Type: cpp main.cpp (3.6 KB, 15 views)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
acperson is offline Offline
20 posts
since Dec 2008
Dec 4th, 2008
0

Re: Need help solving errors: C2533, C2511, C2144.

The problem is at the last line of invoice.h -- a semicolon is required at the end of a class declaration.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Dec 4th, 2008
0

Re: Need help solving errors: C2533, C2511, C2144.

Thanks so much!

That solves two errors, but the C2511 is still there.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
acperson is offline Offline
20 posts
since Dec 2008
Dec 4th, 2008
0

C2511 error - need help solving

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:
C++ Syntax (Toggle Plain Text)
  1. void Invoice::print(Invoice *bill)
  2. { //print values in current bill

Which comes from:

C++ Syntax (Toggle Plain Text)
  1. class Invoice
  2. {
  3. ...
  4.  
  5. void print(Invoice *) const;

Thanks!
Attached Files
File Type: cpp Invoice.cpp (3.6 KB, 11 views)
File Type: h Invoice.h (1.4 KB, 9 views)
File Type: cpp main.cpp (3.6 KB, 12 views)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
acperson is offline Offline
20 posts
since Dec 2008
Dec 4th, 2008
0

Re: Need help solving errors: C2533, C2511, C2144.

Several problems
1) add the const keyword

2) need to add () to function method calls


C++ Syntax (Toggle Plain Text)
  1. void Invoice::print(Invoice bill) const
  2. { //print values in current bill
  3. cout<<"Invoice Number: "<<bill.getInvoiceNum()<<endl<<endl;
  4. cout<<"Part Number: "<<bill.getPartNum()<<endl;
  5. cout<<"Part Description: "<<bill.getPartDesc()<<endl;
  6. cout<<"Quantity Shipped: "<<bill.getQuantityShip()<<endl;
  7. cout<<"Unit Price ($/item): "<<bill.getUnitPrice()<<endl;
  8. cout<<"Sales Tax Rate: "<<bill.getSalesTaxRate()<<endl;
  9. cout<<"Sales Tax Amount: "<<bill.calcSalesTaxAm()<<endl;
  10. cout<<"Shipping Cost: "<<bill.getShipCost()<<endl;
  11. cout<<"Total Cost: "<<bill.calcTotCost()<<endl;
  12. }
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005
Dec 4th, 2008
0

Re: Need help solving errors: C2533, C2511, C2144.

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.
Last edited by Lerner; Dec 4th, 2008 at 11:40 pm.
Reputation Points: 718
Solved Threads: 373
Nearly a Posting Maven
Lerner is offline Offline
2,253 posts
since Jul 2005
Dec 4th, 2008
0

Re: Need help solving errors: C2533, C2511, C2144.

Several problems
1) add the const keyword

2) need to add () to function method calls


C++ Syntax (Toggle Plain Text)
  1. void Invoice::print(Invoice bill) const
  2. { //print values in current bill
  3. cout<<"Invoice Number: "<<bill.getInvoiceNum()<<endl<<endl;
  4. cout<<"Part Number: "<<bill.getPartNum()<<endl;
  5. cout<<"Part Description: "<<bill.getPartDesc()<<endl;
  6. cout<<"Quantity Shipped: "<<bill.getQuantityShip()<<endl;
  7. cout<<"Unit Price ($/item): "<<bill.getUnitPrice()<<endl;
  8. cout<<"Sales Tax Rate: "<<bill.getSalesTaxRate()<<endl;
  9. cout<<"Sales Tax Amount: "<<bill.calcSalesTaxAm()<<endl;
  10. cout<<"Shipping Cost: "<<bill.getShipCost()<<endl;
  11. cout<<"Total Cost: "<<bill.calcTotCost()<<endl;
  12. }
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
Reputation Points: 10
Solved Threads: 0
Newbie Poster
acperson is offline Offline
20 posts
since Dec 2008
Dec 4th, 2008
0

Re: C2511 error - need help solving

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++ Syntax (Toggle Plain Text)
  1. bill[place].print(bill);
Reputation Points: 10
Solved Threads: 0
Newbie Poster
acperson is offline Offline
20 posts
since Dec 2008
Dec 4th, 2008
0

Re: Need help solving errors: C2533, C2511, C2144.

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++ Syntax (Toggle Plain Text)
  1. bill[place].print(bill);
Reputation Points: 10
Solved Threads: 0
Newbie Poster
acperson is offline Offline
20 posts
since Dec 2008
Dec 4th, 2008
0

Re: C2511 error - need help solving

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.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,950 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: C++ graphics
Next Thread in C++ Forum Timeline: Inheritance, and code not running





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC