在c++中应该尽量少使用宏,用模板取而代之是明知的选择。我们可以使用numeric_limits来获取最大值和最小值,例如
#include <iostream>
#include <limits>
#include <iostream>
using namespace std;
int main()
{
	cout << "int_max:"<<std::numeric_limits<int>::max() << endl;
	cout << "INT_MAX:" << INT_MAX << endl;
	cout << "long long_min:" << std::numeric_limits<long long>::min() << endl;
	cout << "unsigned long long_max:" << std::numeric_limits<unsigned long long>::max() << endl;
	
	system("pause");
	return 0;
}
 
结果:
 



















