C + + joins class members like Apple development

Source: Internet
Author: User

It is interesting to see the addition of member variables in Apple development, can we C + + do this? The following macro can help you quickly add class members


#define _MEMBER_ (type, name) private:type _# #name; \

public:type get_# #name () {return _# #name;} \
void set_# #name (type name# #_) {_# #name = # #name # #_;}


ReadOnly

#define _MEMBER_READONLY_ (type, name) Private:type _name;\

Public:type get_name () {return _name;}

Let's take a look at how to use:

Class Request_base
{
Public
Request_base () {
_headers = L "";
_data = "";
_url = L "";
}
virtual bool Get_response (wstring& retstring_) {return true;};
Virtual void* Parse () {return NULL;};
_member_ (wstring, headers);
_member_ (string, data);
_member_ (wstring, URL);
};

Isn't it cool?

C + + joins class members like Apple development

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.