Comment on the confusion of MFC (1) macro and Type Definition

Source: Internet
Author: User

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
//...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.