我收到以下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)