C++ 關鍵字: not
來自 cppreference.com
[編輯] 用法
- 替代運算子:作為
!
的替代
[編輯] 示例
執行此程式碼
#include <iostream> void show(bool z, const char* s, int n) { const char* r{z ? " true " : " false "}; if (n == 0) std::cout << "┌───────────┬─────────┐\n"; if (n <= 1) std::cout << "│ " <<s<< " │ "<<r<<" │\n"; if (n == 1) std::cout << "└───────────┴─────────┘\n"; } int main() { show(not true , "not true ", 0); show(not false, "not false", 1); }
輸出
┌───────────┬─────────┐ │ not true │ false │ │ not false │ true │ └───────────┴─────────┘