cassert C++ · 头文件
断言头文件,提供 assert 宏;条件为 false 时直接终止程序并显示位置。
怎么用
#include <cassert>
小例子
#include <cassert> int x = 5; assert(x > 0);
编译结果
x > 0 时程序继续运行
提醒:assert 是宏,不在 std 命名空间;NDEBUG 宏会禁用所有 assert
在代码里遇到不认识的词?打开代码点读机,点一下就懂 → ← C++全部词条