| | |
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:
Solved Threads: 0
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.
This is where the error occurs.
This is the bookInfo function where the parameters should be passed.
The error
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.
This is just before the main function.
C++ Syntax (Toggle Plain Text)
#include <iostream> #include <iomanip> #include <conio.h> #include <string> using namespace std; //function prototypes int cashier(); //generates sales slip for purchased book(s) int invMenu(); //displays inventory menu void bookInfo(char[14],char[51],char[31],char[31],char[11], int[],double[],double[]); //displays book information int reports(); //displays report information const int SIZE = 20; //holds data for 20 books //global arrays char bookTitle[SIZE][51]; char isbn[SIZE][14]; char author[SIZE][31]; char publisher[SIZE][31]; char dateAdded[SIZE][11]; int qtyOnHand[SIZE]; double wholesale[SIZE]; double retail[SIZE];
This is where the error occurs.
C++ Syntax (Toggle Plain Text)
void lookUpBook() { char title[51]; //variable for title of book int row; cin.ignore(); cout << "\n\tEnter the book title: "; cin.getline(title,51); cout << "\n\tTitle: " << title; for(row=0; row<SIZE; row++) { if(strcmp(bookTitle[row],title) == 0) //if title matches one entered by user { bookInfo(isbn[row],bookTitle[row],author[row],publisher[row],dateAdded[row], qtyOnHand[row],wholesale[row],retail[row]); //ERROR ON PARAMETER 6 break; } else cout << "\n\tNo title matching " << title << " was found."; } }
This is the bookInfo function where the parameters should be passed.
C++ Syntax (Toggle Plain Text)
void bookInfo(char isbn[][14],char title[][51],char author[][31],char publisher[][31], char date[][11],int qty[],double wholesale[],double retail[]) { cout << "\n\n\tSerendipity Booksellers\n"; cout << "\tBook Information\n\n"; cout << "\tISBN: " << isbn << endl; cout << "\tTitle: " << title << endl; cout << "\tAuthor: " << author << endl; cout << "\tPublisher: " << publisher << endl; cout << "\tDate Added:" << date << endl; cout << "\tQuantity-On Hand: " << qty << endl; cout << "\tWholesale Cost: " << wholesale << endl; cout << "\tRetail Price: " << retail << endl; }
The error
C++ Syntax (Toggle Plain Text)
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.
•
•
Join Date: Sep 2008
Posts: 90
Reputation:
Solved Threads: 12
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.
![]() |
Other Threads in the C++ Forum
- Previous Thread: pointers to template class
- Next Thread: Simple Port Scanner - What Do You Think?
| Thread Tools | Search this Thread |
api array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll download dynamiccharacterarray email encryption error file forms fstream function functions game generator getline givemetehcodez graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template text text-file tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





