比如在Test.h中定义变量: _isFirst;

//Test.h头文件
#ifndef __TEST_H__
#define __TEST_H__
class Test{
private:
    bool _isFirst;
};
#endif

然后访问它:

#include "Test.h"
#include "cocos2d.h"
Test::Test(){
    if(_isFirst){ CCLOG("%s","default value is true");}//output:default value is true
}  

c++中bool的默认值为true

 

相关文章:

  • 2022-12-23
  • 2021-12-09
  • 2021-08-21
  • 2022-12-23
  • 2021-08-27
  • 2021-12-15
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-20
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2021-10-24
  • 2022-12-23
相关资源
相似解决方案