Need help solving errors: C2533, C2511, C2144.

Reply

Join Date: Dec 2008
Posts: 20
Reputation: acperson is an unknown quantity at this point 
Solved Threads: 0
acperson acperson is offline Offline
Newbie Poster

Need help solving errors: C2533, C2511, C2144.

 
0
  #1
Dec 4th, 2008
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, 3 views)
File Type: h Invoice.h (1.3 KB, 4 views)
File Type: cpp main.cpp (3.6 KB, 3 views)
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,152
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1436
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

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

 
0
  #2
Dec 4th, 2008
The problem is at the last line of invoice.h -- a semicolon is required at the end of a class declaration.
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.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 20
Reputation: acperson is an unknown quantity at this point 
Solved Threads: 0
acperson acperson is offline Offline
Newbie Poster

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

 
0
  #3
Dec 4th, 2008
Thanks so much!

That solves two errors, but the C2511 is still there.
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 20
Reputation: acperson is an unknown quantity at this point 
Solved Threads: 0
acperson acperson is offline Offline
Newbie Poster

C2511 error - need help solving

 
0
  #4
Dec 4th, 2008
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:
  1. void Invoice::print(Invoice *bill)
  2. { //print values in current bill

Which comes from:

  1. class Invoice
  2. {
  3. ...
  4.  
  5. void print(Invoice *) const;

Thanks!
Attached Files
File Type: cpp Invoice.cpp (3.6 KB, 3 views)
File Type: h Invoice.h (1.4 KB, 2 views)
File Type: cpp main.cpp (3.6 KB, 2 views)
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,152
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1436
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

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

 
0
  #5
Dec 4th, 2008
Several problems
1) add the const keyword

2) need to add () to function method calls


  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. }
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.
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,671
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 261
Lerner Lerner is offline Offline
Posting Virtuoso

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

 
0
  #6
Dec 4th, 2008
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.
Klatu Barada Nikto
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 20
Reputation: acperson is an unknown quantity at this point 
Solved Threads: 0
acperson acperson is offline Offline
Newbie Poster

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

 
0
  #7
Dec 4th, 2008
Originally Posted by Ancient Dragon View Post
Several problems
1) add the const keyword

2) need to add () to function method calls


  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
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 20
Reputation: acperson is an unknown quantity at this point 
Solved Threads: 0
acperson acperson is offline Offline
Newbie Poster

Re: C2511 error - need help solving

 
0
  #8
Dec 4th, 2008
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:

  1. bill[place].print(bill);
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 20
Reputation: acperson is an unknown quantity at this point 
Solved Threads: 0
acperson acperson is offline Offline
Newbie Poster

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

 
0
  #9
Dec 4th, 2008
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:


  1. bill[place].print(bill);
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,152
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1436
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is online now Online
Most Valuable Poster

Re: C2511 error - need help solving

 
0
  #10
Dec 4th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC