3.3 布尔型变量

定义布尔型变量

bool check;

对布尔型变量赋值

check=1;或者check=true;

在定义布尔型变量时直接初始化赋值

bool check=true;

例子:

#include<iostream>
using namespace std;
int main(){
    bool check;
    check = true;
    if (check == true){
        cout << "Hello World!";
    }
    return 0;
}

输出:Hello World!

posted @ 2015-05-20 13:31  cppstudy  阅读(795)  评论(0编辑  收藏  举报