Comment on the confusion of MFC (1) macro and Type Definition
Keywords: C ++, MFC, Macro, Macro, define, typedef
I'm grateful to the MFC LibraryCodeWhen it comes to simplicity, it will be complicated.
See the following common code:
// In User. h
Class ctest
{
PRIVATE:
Int X;
Public:
Void setx (INT setx );
Int getx () const;
Operator int *();
Operator const int * () const;
Void * getsafehandle () const;
};
// In User. cpp
# Include "user. H"
Void ctest: setx (INT setx)
{
X = setx;
}
//...
We (the author of MFC) think that such code is too simple, not deep enough, lack of connotation, and not chewy. Include our header file to improve the overall image of the Code. Our slogan is: let the blue keyword 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;
Typedef int * lpint;
Typedef const int * lpcint;
Typedef void * hobj;
Look! We did. From then on, our Customer Code will be written as follows:
// In User. h
# Include "minimfc. H"
User_class ctest
Begin_class_declaration
Private_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
//...