小编Ant*_*ony的帖子

为什么即使我没有#include <algorithm>,仍然可以使用std :: max和std :: min?

#include <iostream>

int main()
{
   int value1 = 1, value2 = 10;
   std::cout << "Min = " << std::min(value1,value2) <<std::endl;
   std::cout << "Max = " << std::max(value1,value2)<< std::endl;              
} 
Run Code Online (Sandbox Code Playgroud)

据我所知,minmax函数的定义<algorithm>.

如果我没有告诉预处理器包含<algorithm>为什么代码仍然有效?

c++ include-guards preprocessor-directive

16
推荐指数
1
解决办法
2万
查看次数