Click to See Complete Forum and Search --> : Funniest compiler error I've seen, but it's serious!!!


Hardeep Singh
April 26th, 1999, 08:35 AM
I'm using CStringArrays in my program, and I've written a routine to sort them. I know the internal code works, because I had tested it. But when I make it a function with the following prototype:

void sort(CStringArray,int);



I get the following compiler error:

"Cannot convert parameter 1 from 'class CStringArray' to 'class CStringArray'"

How the hell do you explain that?
Please, this may sound funny, but it's a serious problem. Right now I'm compelled to paste the code for my sort routine everywhere I need it... How do I get rid of this silly error?

SKB
April 26th, 1999, 08:48 AM
The CStringArray does not know how to copy itself so that it can be passed into the function. If you was to pass the CStringArray as a reference it will work.

void sort(CStringArray &,int);

When values are passed in to a function then the value needs to be copied, unless it is a reference or a pointer to the object.

April 26th, 1999, 08:48 AM
The message means that CStringArray does not have an assignment operator and thus, when you call the function, you are not able to "convert" (by assignment) the parameter passed in to the function parameter. Try using a pointer to CStringArray as your function parameter.

Franky Braem
April 26th, 1999, 08:49 AM
Pass your CStringArray by reference :

sort(CStringArray &, int);



The problem here is that there's no copy constructor for the CStringArray-class.