映射在头文件c++

map in header file c++

本文关键字:c++ 文件 映射      更新时间:2023-10-16

简单问题....

我有一个头文件叫bag…

#include <map>
#include <iostream>
#include <string>
using namespace std;

class Bag
{
public:
Bag();

map <const string str, int number> items;
private:
};
#endif

在实现中,我想插入一些东西到包中:

#include <string>
#include <fstream>
#include <map>
#include "Bag.h"
using namespace std;
Bag::Bag()
{
items["brush"] = 4;
}

但是由于某些原因,我不能访问项目。我做错了什么????

谢谢!

废话!出于某种原因,我试图插入一个值的名称与值类型字段。谢谢,查德,我觉得你治好了我!

map <const string, int> items;