Hello,

I have been trying to figure this out for several hours and would so so so so greatly appreciate some help..

This is the error message I am receiving when I try to compile my program..

/Barclay_Colin_Assign7_Final.cpp:393: error: no matching function for call to 'bookinfo(int&, char [51], char [14], char [31], char [31], char [11], int&, double&, double&)'
note: candidates are: void bookinfo(int, char*, char*, char*, char*, int*, double*, double*)
void bookinfo(int, char*, char*, char*, char*, char*, int*, double*, double*)

WHatttt!!???

Does this function call and definition not match ?

Recommended Answers

All 7 Replies

>>Does this function call and definition not match ?

Bingo :) My guess is that you have two overloaded functions named bookinfo, but neither of them have exactly the same arguments as the one your program is attempting to call. Notice that one passes some parameters by reference while the other two pass by pointer.

More specifically, this is your problem (the one in bold): bookinfo([B]int&[/B], char [51], char [14], char [31], char [31], char [11], int&, double&, double&) Try changing it to just [B]int[/B] , as int& is almost equivalent to int* , which is not the type of the first argument in your function prototype.

commented: very helpful , Thank You +1

The last two arguments have similar problems.

commented: Very helpful ..Thank You +1

THANK YOU for responding ... !! I appreciate the help ...

Ok, So I have been playing with this problem and it has morphed into a new one !??? Below I am listing the function prototype, definition and call... I will also list the array definitions and the const ints I used.

const int BOOK_TITLE = 51;
const int ISBN = 14;
const int AUTHOR = 31;
const int PUBLISHER = 31;
const int DATE_ADDED = 11;
const int QTYONHAND = 20;
const int WHOLESALE = 20;
const int RETAIL = 20;
const int TWENTY = 20;

char booktitle [TWENTY][BOOK_TITLE];
char isbn [TWENTY][ISBN];
char author [TWENTY][AUTHOR];
char publisher [TWENTY][PUBLISHER];
char dateadded [TWENTY][DATE_ADDED];
int qtyonhand [QTYONHAND];
double wholesale [WHOLESALE];
double retail [RETAIL];


PROTOTYPE 

voidbookinfo
(int,char[],char[],char[],char[],char[],int[],double[],double[]);

DEFINITION 

void bookinfo( int row,char booktitle[TWENTY],char isbn[TWENTY],char author[TWENTY],char publisher[TWENTY],char dateadded[TWENTY],int qtyonhand[QTYONHAND],double wholesale[WHOLESALE],double retail[RETAIL])
{
        cout << "Book Title\n";
    cout << booktitle[row];
    cout << endl;

    cout << "ISBN";
    cout << isbn[row];
    cout << endl;

    cout << "Author's name";
    cout << author[row];
    cout << endl;

    cout << "Publisher's name";
    cout << publisher[row];
    cout << endl;

    cout << "Date Added";
    cout << dateadded[row];
    cout << endl;

    cout << "Quantity on hand";
    cout << qtyonhand[row];
    cout << endl;

    cout << "Wholesale price";
    cout << wholesale[row];
    cout << endl;

    cout << "Retail price";
    cout << retail[row];
    cout << endl;
}

FUNCTION CALL

//row is assigned as follows  -- int row = 0;

bookinfo(row,booktitle[row], isbn[row],author[row],publisher[row],dateadded[row],qtyonhand[row],wholesale[row],retail[row]);

AND BELOW IS THE NEW SET OF ERRORS THE COMPLIER IS KICKING OUT...

error: invalid conversion from 'int' to 'int*'

error: cannot convert 'double' to 'double*' for argument '8' to 'void bookinfo(int, char*, char*, char*, char*, char*, int*, double*, double*)'

ANY IDEAS ??

If you are calling your function with a specific element of each of those arrays, you are no longer passing an int a[] you are passing in a plain int. Your definition is treating it like you are sending in the whole array of size 20.
If you are letting your function do the stepping through the array leave the definition as is and pass in e.g. booktitle (without any []) in the function call but if you are stepping through the array in main and only want your function to see one element at a time, change your definition (and declaration of course) to reflect that.

Also, please use the code tags next time even if it is just a few lines of code //your code here

you could try using the &symbol before the variable but that might just put in memory location of those arrays.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.