[英]C++ “map is not a type” error
This is my header file: 这是我的头文件:
/**
* Job.h
*
**/
#ifndef JOB_
#define JOB_
#include <map>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <iomanip>
#include <vector>
class Job {
private:
int resourceId;
int inputRepresentation;
int outputRepresentation;
//Effects associative array
//Maps an effect to a map of it's attributes
//effectsMap[effect][attribute]=value
map< std::string, map<std::string, int> > *effectsMap;
public:
//constructors
Job();
Job(int resId, int inputRep, int outputRep);
//destructor
virtual ~Job();
//getters
int getInputRepresentation() const;
int getOutputRepresentation() const;
int getResourceId() const;
//setters
void setInputRepresentation(int inputRepresentation);
void setOutputRepresentation(int outputRepresentation);
void setResourceId(int resourceId);
void setRepresentations(std::map *rep);
void addEffect(std::string effect, map<std::string, int> attributesMap);
};
#endif
Now Ii will get to the point: 现在,II将会指出:
void setRepresentations(std::map *rep)
Gives the following error: "map is not a type" This is weird because it looks like eclipse manages to properly link to the stl library... And I do have a private field of map that seems to be fine. 给出以下错误:“地图不是类型”这很奇怪,因为它看起来像eclipse设法正确地链接到stl库...而且我确实有一个地图的私有字段,这似乎很好。
Any ideas? 有任何想法吗?
您需要指定地图的完整类型,包括< >
内的类型:
void setRepresentations(std::map<std::string, int> *rep);
您在地图前面缺少std::
。
std:map
is a template , not a type . std:map
是模板 ,而不是type 。 A type would be std::map<std::string, int>
. 类型为
std::map<std::string, int>
。
What exactly is setRepresentations
supposed to do? setRepresentations
应该做什么? Why does the signature not fully specify what type of map
it should be working with, just like addEffect
does? 为什么签名没有像
addEffect
那样完全指定应使用的map
类型?
您需要为map指定名称空间,因此应为std::map
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.