I've just changed an ObjC
file to ObjC++
by changing the extension from .m
to .mm
. Now, one of my methods gives the error: Expected expression
The following code is an example that works fine in ObjC
but NOT in ObjC++
:
- (float)sum:(float)a and:(float)b
{
return a+b;
}
- (void)run
{
float s = [self sum:1.5f and:2.5f]; // ERROR HERE
NSLog(@"Sum = %.1f", s);
}
The only thing I've changed is the file extension. Any idea what's going on and how to fix it? Thanks!
and
is a reserved word in C/C++...
(See comments under question)