Visual studio 2013 C++ standard library
Visual studio 2013 C++ standard library
我使用visual studio 2013在c++中编程以下代码:
#include <iostream>
using namespace std;
int main()
{
std::cout << "Please enter two integers: " << std::endl;
int v1 = 0, v2 = 0;
std::cin >> v1 >> v2;
int current = std::min(v1, v2);
int max = std::max(v1, v2);
while (current <= max)
{
std::cout << current << std::endl;
++current;
}
return 0;
}
这段代码的目的是解决:"编写一个程序,提示用户输入两个整数。打印这两个整数指定范围内的每个数字。"
一开始我很困惑,但在搜索后发现std min/max可以帮助。然而,当我尝试编译时,我得到错误,告诉我命名空间"std"没有成员"min"和成员"max"。
我做错了什么,还是Visual Studio 2013不包括min/max?
我看你好像忘了#include <algorithm>
。
你的代码应该是这样的:
#include <iostream>
#include <algorithm> // notice this
using namespace std;
int main()
{
std::cout << "Please enter two integers: " << std::endl;
int v1 = 0, v2 = 0;
std::cin >> v1 >> v2;
int current = std::min(v1, v2);
int max = std::max(v1, v2);
while (current <= max)
{
std::cout << current << std::endl;
++current;
}
return 0;
}
添加
#include <algorithm>
使用前 std::min
或 std::max
相关文章:
- Boost Graph Library,修复节点大小
- SFML library: http request
- 解决"ld: library not found for -ltensorflow_framework.2.3.0"
- Linking library C++
- 在VS2019项目中集成ImageMagick:x64-windows-static library
- OpenSSL fips in C++ wrapper Library 如何?错误:指纹不匹配
- C++ class vs a library
- C++ library with Tensorflow on Android
- 我需要安装什么才能获得在Windows Server 2012 R2 Standard上运行C++hello world
- CMake:尝试在 Jenkins 构建机器上运行时出现"Linked Library"错误 (0xc0000135)
- 将 c++ cmake-library 构建发布到本地存储库时出现 Gradle 错误
- 为什么"non-standard syntax; use '&' to create a pointer to member"在 CTOR 中使用线程?
- 为什么'allocate in one library and free in the other'是错误的
- 函数参数中的向量"Non-standard syntax"错误
- 链接 library.lib 使用 setup.py.
- 什么是"Reading unbounded stream from standard input (Memory Management)"的例子
- 在 Xcode 4.5 中,"C++ Standard Library"和"C++ Language Dialect"的"Compiler Default"是什么?
- Visual studio 2013 C++ standard library
- "STL"和"C++ Standard Library"之间是否有明确的分离定义?
- 下面粗体的句子,在Nocolai Josuttis "The Standard Library"的书中,我不清楚