I try to use the formatting service that is described in chapter 12 and have a trivial problem writing the method CreateInstance of the class MyFormatImplementation. The line
IFormatServiceCallbackPtr p = new CBaseObject< MyFormatImplementation >();
gives the error: error C2061: syntax error : identifier 'CBaseObject’
I guess it is because I’m not including the right header file, but I can’t seem to find the right one
#include “RSPlugin.h”, which you state you are using, should be sufficient.
It might just be a namespace issue. Try putting this at the top of your source file, somewhere after your include statements:
using namespace RS;
CBaseObject is defined under that namespace, so the compiler won’t recognize it unless the namespace is included. You can also skip the ‘using’ declaration and just prepend RS:: to CBaseObject anytime you refer to it, for instance, RS::CBaseObject. But with the ‘using’ statement, you avoid having to know which items are under RS and which are not, leaving you free to just refer to the type name unqualified.
You might also want to put this:
using namespace RSServices;
in your source files, to avoid needing to worry about qualifying any of those types, too.