DECLARE_MESSAGE_MAP() Bug - C2248?
> I added ~CMapsApp() to CMapsApp() below the DECLARE_MESSAGE_MAP() line and
> got the following error:
> Maps.cpp(40): error C2248: 'CMapsApp::~CMapsApp' : cannot access protected
> member declared in class 'CMapsApp'
> If I move the line above the DECLARE_MESSAGE_MAP() line, it compiles OK.
As the error message explains, your destructor is protected and you cannot
create instances of classes with a protected destructor unless your are
doing it from a member of that class or a derived class or from a friend. So
a protected section should begin somewhere above the line following
Now take a look at the definition of DECLARE_MESSAGE_MAP and there it is:
private: ... protected: ...
My unimportant advice: Don't put your own declarations among that wizard
generated chaos. Once a wizard has generated code for a class, put a comment
at the beginning of the class definition (Wizard country ahead) and put all
your declarations above the wizard's stuff. To play it safe, add public:
protected: private: just below the comment. That will prevent class wizard
from adding declarations to your declarations:
class YourClass: ...
... Put your declarations here ...
// Danger! Wizard Ahead!
... Initial wizard code follows ...