Assert C++

/************************************************************************/
/* 
1、debug版本中,assert相应的宏会被执行。
	release版本中,assert相应的宏不会被执行。
2、原理
	#include 
	void assert( int expression );
	assert的作用是先计算表达式 expression ,如果其值为假(即为0),
	那么它先向stderr打印一条出错信息,然后通过调用 abort 来终止程序运行
3、注意频繁的调用会影响程序性能
4、在#include之前加上#define NDEBUG ,可以禁用后面所有的assert宏
*/
/************************************************************************/
#define NDEBUG 

#include
#include
#include

using namespace std;

int main()
{
	assert(0);

	cout << "......"<<"//" << endl;
	system("pause");

	return 0;
}

 

你可能感兴趣的:(C++,札记)