<分区>
我正在尝试定义一个可以按字符串搜索的函数指针表。 我定义了以下模板类,但我在使用静态成员时遇到了问题。
我的错误是
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_;
你能帮帮我吗?