Non-discussion MFC

xiaoxiao2021-03-06  52

非 MFC (1) Confusion of macro and type definition

Non-discussion MFC (1) macro and type definition confusion Keywords: C , MFC, macro, macro, define, Typedef has feeling that the MFC library code is simple, so it is a mystery, make a statement, and smile. Please see a common code: // in user.hclass ctest {private: int x; public: void setx; int getX () const; operator int * (); operator const in / () const; void * GetSafehandle () const;}; // in user.cpp # include "user.h" void ctest :: setx (int setx) {x = setx;} // ... we (author of MFC) think this The 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 * LPINT; TYPEDEF Const Int * lpcint; type! We did it. Since then, our client code will be written like 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 BEGIN_FUNCTION_DEFINITION x = setX "user.h" AFX_RETURN_VOID_FUNCTION CTest :: setX (INT setX); END_FUNCTION_DEFINITION // ...

Non-discussion MFC (2) logic is not complete

Author: cphj Source: Unknown Add Time: 2004-6-29 Views: