Cocos2d-x static variable

Source: Internet
Author: User

In cocos2d-x. when the static variable is declared in the H file, the error "cannot be parsed" will occur during compilation and running. This is because we reference the C ++ habit of being static) errors Caused by variable declaration in header files.

# Ifndef _ a_h _ # DEFINE _ a_h _ # include "cocos2d. H "Class A {public: static int getint (); // obtain the created static (static) variable protected: ();~ A () ;};# endif
# Include "A. H" using namespace cocos2d; static int staticint = 0; // The static variable Declaration must be defined here. A (void) {} ::~ A (void) {} int A: getint () {return staticint ;}

 

Cocos2d-x static variable

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.