943,748 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Marked Solved
  • Views: 440
  • C++ RSS
Apr 12th, 2009
0

Confusion with conversion of type1 to type2

Expand Post »
Hi guys! I've worked so hard on this really long program. I think I'll just post the relevant subprograms. I hope it's still easy to understand.

This is just before the main function.
C++ Syntax (Toggle Plain Text)
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <conio.h>
  4. #include <string>
  5. using namespace std;
  6.  
  7. //function prototypes
  8. int cashier(); //generates sales slip for purchased book(s)
  9. int invMenu(); //displays inventory menu
  10. void bookInfo(char[14],char[51],char[31],char[31],char[11],
  11. int[],double[],double[]); //displays book information
  12. int reports(); //displays report information
  13.  
  14. const int SIZE = 20; //holds data for 20 books
  15. //global arrays
  16. char bookTitle[SIZE][51];
  17. char isbn[SIZE][14];
  18. char author[SIZE][31];
  19. char publisher[SIZE][31];
  20. char dateAdded[SIZE][11];
  21. int qtyOnHand[SIZE];
  22. double wholesale[SIZE];
  23. double retail[SIZE];

This is where the error occurs.
C++ Syntax (Toggle Plain Text)
  1. void lookUpBook()
  2. {
  3. char title[51]; //variable for title of book
  4. int row;
  5.  
  6. cin.ignore();
  7. cout << "\n\tEnter the book title: ";
  8. cin.getline(title,51);
  9. cout << "\n\tTitle: " << title;
  10.  
  11. for(row=0; row<SIZE; row++)
  12. {
  13. if(strcmp(bookTitle[row],title) == 0) //if title matches one entered by user
  14. {
  15. bookInfo(isbn[row],bookTitle[row],author[row],publisher[row],dateAdded[row],
  16. qtyOnHand[row],wholesale[row],retail[row]); //ERROR ON PARAMETER 6
  17. break;
  18. }
  19. else
  20. cout << "\n\tNo title matching " << title << " was found.";
  21. }
  22. }

This is the bookInfo function where the parameters should be passed.
C++ Syntax (Toggle Plain Text)
  1. void bookInfo(char isbn[][14],char title[][51],char author[][31],char publisher[][31],
  2. char date[][11],int qty[],double wholesale[],double retail[])
  3. {
  4.  
  5. cout << "\n\n\tSerendipity Booksellers\n";
  6. cout << "\tBook Information\n\n";
  7. cout << "\tISBN: " << isbn << endl;
  8. cout << "\tTitle: " << title << endl;
  9. cout << "\tAuthor: " << author << endl;
  10. cout << "\tPublisher: " << publisher << endl;
  11. cout << "\tDate Added:" << date << endl;
  12. cout << "\tQuantity-On Hand: " << qty << endl;
  13. cout << "\tWholesale Cost: " << wholesale << endl;
  14. cout << "\tRetail Price: " << retail << endl;
  15. }

The error
C++ Syntax (Toggle Plain Text)
  1. error C2664: 'bookInfo' : cannot convert parameter 6 from 'int' to 'int []'

I'm so sure that when this error is resolved, the new error will be "cannot convert parameter 7 from 'double' to 'double[]'. I don't want this to happen. I've worked so hard...

I'm just a newbie, so please go easy on me. I'm sorry.
Last edited by queensrose; Apr 12th, 2009 at 6:07 am.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
queensrose is offline Offline
4 posts
since Mar 2009
Apr 12th, 2009
0

Re: Confusion with conversion of type1 to type2

The function is expecting an int[] (array/pointer) type and you pass an int, instead you should write the function as:
void bookInfo(char[14],char[51],char[31],char[31],char[11],int,double,double); It would also be better if you used strings from the <string> header instead of arrays of char s.
Last edited by unbeatable0; Apr 12th, 2009 at 7:02 am.
Reputation Points: 42
Solved Threads: 13
Junior Poster in Training
unbeatable0 is offline Offline
90 posts
since Sep 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

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: pointers to template class
Next Thread in C++ Forum Timeline: Simple Port Scanner - What Do You Think?





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


Follow us on Twitter


© 2011 DaniWeb® LLC