expected primary-expression before 'char'

EDITED:

I am getting the error

expected primary-expression before "]" token

for this constructor:

con::con(char data[]){do( data[]);}

where con is of course the constructor, and "do" its function.

its prototype is con(char data[ ]);

can someone tell me what the problem is (not only what to add to the code)

Thanks!





Last edited on
do is a keyword in C++, usually paired with the while keyword.. Pick a different name for your function.
Instead, you should have this:

con::con(char data[]){do( data );} //Moschops is right, use another word

The square brackets aren't necessary when you're referring to the array itself. You can think that char data[] is of type char [] so the square brackets are part of the type. Of course you would need the brackets when accessing a particular element of the array.
Last edited on
Topic archived. No new replies allowed.