2

我知道有十亿个类似的主题,但我在其中看到的任何建议都没有帮助我解决这个问题......这是在一个保存为 header.h 的文件中

#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <map>

using namespace std;
class Handler {
public:
    Handler();
    ~Handler();

    bool handle(int client);
    void giveMaps(map<string, string> host, map<string,string> media>);

private:
    map<string, string> hosts;
    map<string, string> mediaLookup;
    char buf_[1600];
    char* getCurrentDate();

};

我的错误是“handler.h:18: error: expected ',' or '...' before '>' token”,原文中的第 18 行是“void giveMaps(map host, map media>);”

我已经尝试将这两个地图以及地图内的所有字符串都声明为 const,但到目前为止我什么都没有。我很肯定这很简单,我只需要另一双眼睛才能看到它......

4

3 回答 3

3

结尾有一个额外>

void giveMaps(map<string, string> host, map<string,string> media>);
于 2012-10-19T23:55:34.247 回答
3

有一个额外的>。请删除(它在语句之后的倒数第三个media):

更新后的声明应如下所示:

void giveMaps(map<string, string> host, map<string,string> media);
于 2012-10-19T23:56:44.267 回答
1

除了给出的其他建议外,以下内容是不正确的:

#include <string.h>

你应该放弃,.h所以你只有:

#include <string>
于 2012-10-20T00:01:14.543 回答