Confusion with conversion of type1 to type2

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Mar 2009
Posts: 4
Reputation: queensrose is an unknown quantity at this point 
Solved Threads: 0
queensrose queensrose is offline Offline
Newbie Poster

Confusion with conversion of type1 to type2

 
0
  #1
Apr 12th, 2009
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.
  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.
  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.
  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
  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.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 90
Reputation: unbeatable0 is an unknown quantity at this point 
Solved Threads: 12
unbeatable0 unbeatable0 is offline Offline
Junior Poster in Training

Re: Confusion with conversion of type1 to type2

 
0
  #2
Apr 12th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
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