非 MFC (1) Confusion of macro and type definition
Keywords: C , MFC, Macro, Macro, Define, Typedef
I feel that the MFC library code is simply, so I gave a declaration, make a statement, and smiled.
Please see a common code:
// in user.hclass ctest {private: int x; public: void setx; int getX () const; operator int * (); operator const * () const; void * getsafehandle () const; ;
// in User.cpp # include "user.h" void ctest :: setx (int setx) {x = setx;} // ...
Our (author of MFC) thinks that such code is too shallow, not deep enough, lack of connotation, no chewy. Hurry with our header file, it can improve the overall image of the code. Our slogan is: let the blue key disappear on the screen.
// in minimfc.h # define USER_CLASS class # define BEGIN_CLASS_DECLARATION {#define END_CLASS_DECLARATION}; # define PRIVATE_MEMBER private: #define PROTECTED_MEMBER protected: #define PUBLIC_MEMBER public: #define OPERATOR_OVERLOAD operator # define CONSTANT_MEMBER_FUNTION const # define BEGIN_FUNCTION_DEFINITION {#define END_FUNCTION_DEFINITION} Typedef void AFX_RETURN_VOID_FUNCTION; typedef int tent; typedef const * lpcint; typedef void * hobj;
Look! We did it. Since then, our customer code will write this:
// in user.h # include "minimfc.h" USER_CLASS CTestBEGIN_CLASS_DECLARATIONPRIVATE_MEMBER INT x; PUBLIC_MEMBER AFX_RETURN_VOID_FUNCTION SetX (INT setX); INT GetX () CONSTANT_MEMBER_FUNTION; OPERATOR_OVERLOAD LPINT (); OPERATOR_OVERLOAD LPCINT () CONSTANT_MEMBER_FUNTION; HOBJ GetSafeHandle () CONSTANT_MEMBER_FUNTION; END_CLASS_DECLARATION
// in User.cpp # include "user.h" AFX_RETURN_VOID_FUNCTION CTEST :: SetX (int setx) begin_function_definition x = setx; end_function_definition // ...