打开VS 2010中的math.h可以看到,对于一些数学中的常量,math.h中使用了条件编译指令# if defined...
,所以要使用这些常量,需要首先在#include<math.h
前定义’#define _MATH_DEFINES_DEFINED’。
#include<iostream>
using namespace std;
#define _USE_MATH_DEFINES
#include<math.h>
void main()
{
cout<<M_PI<<endl;
}