下面的C++代码(关于shared_ptr)有什么问题
What is wrong with following C++ code (regarding shared_ptr)
我正试图加快使用shared_ptr的速度,但我似乎不明白为什么以下代码无法编译。
在头文件中,私有成员声明:
std::map<std::string, str::tr1::shared_ptr< std::vector<int> > > *_myMap;
在构造函数中,尝试实例化上面的对象:
_myMap = new map<string, std::tr1::shared_ptr< vector<int> > >();
错误消息:
Test.cpp:14:68: error: cannot convert ‘std::map<std::basic_string<char>, std::tr1::shared_ptr<std::vector<int> > >*’ to ‘std::map<std::basic_string<char>, std::vector<int> >*’ in assignment
我想一步一步地转换我的指针,但我似乎不明白上面为什么会出错。有人能提出建议吗?谢谢
编辑:
我发现了原因。我打开了两个vim实例,其中一个正在写入一个临时交换文件,而在编译时并没有真正查看更改。谢谢你们的投入。
您不可能逐字逐句地发布代码。
您的标题必须显示std::map<std::string, std::vector<int> > *_myMap;
你确定你的建筑是否正常?尝试全新构建。
您确定这是当前的定义吗?错误显示您的地图在标题中声明为
std::map<std::string, std::vector<int> >*
相关文章:
- 警告处理为错误这里有什么问题
- 最小硬币更换问题(自上而下方法)
- 为"adjacent"变量赋值时出现问题
- 我的神经网络不起作用 [XOR 问题]
- 在Ubuntu 16.04上安装Cilk时出现问题
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 编译包含字符串的代码时遇到问题
- Project Euler问题4的错误解决方案
- 问题:什么是QAbstractItemView::NoEditTriggers的反面
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 在进程中对同一管道进行读取和写入时C++管道出现问题
- 静态数据成员的问题-修复链接错误会导致编译器错误
- C++ 雷神库 - 使用资源加载器类时出现问题(不命名类型)
- 一个关于在C++中重载布尔运算符的问题
- 首要问题的答案让值班员搞错了
- setlocale的C++土耳其字符串问题
- 如何重构类层次结构以避免菱形问题
- 基于boost的程序的静态链接——zlib问题
- C++格式化输出问题
- 从const ptr*转换为ptr*时出现问题