I have a the following method definition in my class:
virtual Calc* Compile(
Evaluator* evaluator, ResolvedFunCall* fun_call, string* error);
For some reason, GCC complains that:
error: 'Compile' declared as a 'virtual' field
Any ideas why it would believe Compile to be a field, instead of a method?
I get that error when the first parameter doesn’t make sense to it. Check that
Evaluatoris known as type:To find out whether something is a object or function declaration, the compiler sometimes has to scan the whole declaration. Any construct within the declaration that could possibly form a declaration is taken to be a declaration. If not, then any such construct is taken to be an expression. GCC apparently thinks because
nonsenseis no valid type, it can’t be a valid parameter declaration, and thus falls back treating the whole declaration as a field (note that it says in additionerror: expected ';' before '(' token) . Same thing in local scope