#include<iostream>
#include<cassert> 
using namespace std;

int main()
{
	int i = 5;
	assert(5 == i);
	cout << "hello" << endl;
	
	assert(4 == i);
	cout << "world" << endl;

	return 0;
}


       运行该程序,发现有“异常”提示,这就是assert宏的作用. (仅在debug版本中有效)

 


本文转载:CSDN博客