我正在尝试定义一个可以通过字符串搜索的函数指针表。我定义了以下模板类,但静态成员有问题。
我的错误是
test.cpp:18: error: expected constructor, destructor, or type conversion
before ‘Attribute’
即使添加了一个构造函数,它也不起作用:你知道编译器告诉我的原因是什么,以及这段简单的代码中缺少什么吗?
#include<iostream>
#include<map>
#include<boost/function.hpp>
using namespace std;
using namespace boost;
template<class T>
class Attribute {
public:
typedef map<string, boost::function<void(T*,string) > > Params;
static Params params_;
};
template<class T>
T::Params Attribute<T>::params_;
你能帮助我吗?