我试图做一个声明STL的地图,像这样的模板参数: (假设T作为类型名,像这样:template <class T>
)初始化STL类与模板参数
map<T, T> m;
(在.h文件中)
它编译好。现在在我的cpp文件中,当我想插入地图时,我无法。我在intellisense上获得的唯一方法是“at”和“swap”方法。
任何想法?请人吗?
在此先感谢。
这里是示例代码:
#pragma once
#include <iostream>
#include <map>
using namespace std;
template <class T>
class MySample
{
map<T, T> myMap;
//other details omitted
public:
//constructor
MySample(T t)
{
//here I am not able to use any map methods.
//for example i want to insert some elements into the map
//but the only methods I can see with Visual Studio intellisense
//are the "at" and "swap" and two other operators
//Why???
myMap.
}
//destructor
~MySample(void)
{
}
//other details omitted
};
任何人都可以吗? – lat
发表一些代码...我们不在你的屏幕前,所以你可能想帮助我们理解你的问题,如果你想要的答案... – Macmade
我添加了一些示例代码。让我知道我所做的是错的。 – lat