c++ 中bool 的默认值

比如在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

原文地址:https://www.cnblogs.com/kingBook/p/4602450.html