I found how to fix this example but not my original problem.
I inserted this C++ function into an extended objective C file (a ".mm" file which allows C++ functions). When I insert it within the "@implementation" section, it's rejected by the compiler. But when I move it above, outside that section, it is accepted. Also, when I place it in an include file, whether inside or outside of a class declaration, it is also accepted.
This fix does not apply to my original problem.
I'll need to prepare another example to illustrate my problem.