宏assert的用法.txt
来自「里面的代码是自己写的,参考书是thingking in c++,代码有详细的说明」· 文本 代码 · 共 23 行
TXT
23 行
/*本程序对应于P197。
* 本程序是为了说明 assert()宏的用法
*注意点1:when you use assert(),you give it an argument that is an expression
*you are "asserting to be true."the preprocessor generates code that will
*test the assertion.If the assertion isn't true ,the program will stop after
*issuing an error message telling you what the assertion was and that it
*failed.
*注意点2:When you finished debugging,you can remove the code genereted
* by the macro by placing the line : #define NDEBUG in the program before
*the inclusion of <cassert>.
*/
#include<iostream>
//#define NDEBUG //参考注意点2的说明
#include<cassert>
using namespace std;
int main()
{
int i = 100;
assert(i != 100); //fails
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?