小编dre*_*o87的帖子

获取错误表达式必须在c ++中具有类类型

我收到以下IntelliSense错误:

表达式必须具有类类型f:\ C++\prj\map1\map1\testMap1.cpp 11

这是指我的代码中的以下行(如下所示):

theMap.insert(1, "one");

我无法弄清楚问题是什么.它似乎与声明没有关系theMap,但每次我尝试调用方法时theMap都会得到错误.这是我的代码:

map1.h

#ifndef MAP_H
    #define MAP_H
    #include <list>
    #include <utility>
    using namespace std;

//pair class definition
template<typename F, typename S>
class Pair
{
public:
Pair(const F& a, const S& b);
F get_first() const;
S get_second() const;
private:
F first;
S second;
};

template<typename F, typename S>
inline Pair<F, S>::Pair(const F& a, const S& b):first(a),second(b){}

template<typename F, typename S>
inline F Pair<F, S>::get_first() const
{
    return first;
}

template<typename F, …
Run Code Online (Sandbox Code Playgroud)

c++ compiler-errors

4
推荐指数
1
解决办法
8193
查看次数

标签 统计

c++ ×1

compiler-errors ×1