尝试对Integer数组进行排序,并在进行一些谷歌搜索后,使用了std::sort并伴随了以下错误:namespace "std" has no member "sort",找到了解决方案。

只是为了反驳我没有使用std namespace 的任何限制,这是我的 header :

#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
using namespace std;

最佳答案

加:

#include <algorithm>

std::sort() 引用页中所述。

有关讨论using namespace std;的信息,请参见Using std NamespaceWhy is "using namespace std" considered bad practice?和许多其他问题。

09-10 00:23
查看更多