g ++抱怨STD功能

Uys*_*des -5 c++ g++ std

我有一段下载的源代码,当尝试使用g ++编译器通过Cygwin进行编译时,编译器给出了一个错误,指出'transform'函数在此范围内未声明...

我正在使用std命名空间,我有正确的标头.我不确定它为什么不编译..语法看起来正确

这是代码块部分.

string tolower (const string & s)
  {
    string d = s;
    transform(d.begin(), d.end(), d.begin(), (int(*)(int)) tolower);
    return d;
  }  // end of tolower
Run Code Online (Sandbox Code Playgroud)

这是我的标题部分:

#include <fcntl.h>
#include <signal.h>
#include <sys/time.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <unistd.h>

// standard library includes ...

#include <string>
#include <list>
#include <map>
#include <set>
#include <vector>
#include <stdexcept>
#include <fstream>
#include <iostream>
#include <sstream>
#include <ios>
#include <iterator>

using namespace std; 
Run Code Online (Sandbox Code Playgroud)

jua*_*nza 5

您需要包含适当的标头std::transform:

#include <algorithm>
Run Code Online (Sandbox Code Playgroud)

您还应该避免using namespace std;在标头中的全局命名空间中,污染包含头文件的任何代码的全局命名空间.

看到这篇文章using namespace std.