Compile error: "some operator expected"

 

Hello to everybody,

I am getting mad in dealing with array passing to a function.

I have defined a function called clear(), with the following prototype

void clear(string &[],int);

and defined in such way:

void clear(string &myArray[],size) {


}

But when I call the clear function 

string stringArray[5];
clear(stringArray,5);

I got this compilation error:

'clear -some operators expected'

What does it mean ?

How could I fix it ?

 
Invalid definition
void clear(string &myArray[], int size) {


}


 

Yes whoreder,

I did a mistake in writing my post... in my code, (those it does not compile) I correctly wrote

void clear(string &myArray[], int size) {


}

But it does not compile.

Could you help me, please ?

 
DeltaElectronics: But it does not compile.
Do you really expect an answer? We can't see all your broken code, nor your error message. There are no mind readers here and our crystal balls are cracked.
 
DeltaElectronics:

Yes whoreder,

I did a mistake in writing my post... in my code, (those it does not compile) I correctly wrote

But it does not compile.

Could you help me, please ?

Delta, if you wrote something like

   bool isNewBar = isNewBar();

   void isNewBar() { … }

the compiler does not complain. However, when it is 

   bool isNewBar = isNewBar(2);

   void isNewBar(int var1) { … }

you have this error.

Since you used 'clear' as the function name, a rather ordinary word, maybe you have declared a variable with the same name. If this is what happened, just rename the function to isNewBar_ (or whatever you like).


   

 

I know this is a late answer, but it may help those who come here looking for a solution to their problem.


There's a strong possibility that you have a (possibly globally declared) variable with the same name as the function.

This error may also show up if two variables, one in a function declaration (such as 'size' in your case), and a globally declared variable have the same name.

 

To those who came here, this also happens when you dont set brackets in function definition, it thinks it is not array and expects something


bool isEmaDowntrend(float emaFasterArray, float emaSlowerArray)
      {
         return emaFasterArray[0] < emaFasterArray[0];
      }

// Should be this:

bool isEmaDowntrend(float& emaFasterArray[], float& emaSlowerArray[])
      {
         return emaFasterArray[0] < emaFasterArray[0];
      }
Reason: