假设我有一个模板类IO<T>
和另一个模板类MembershipFunction<T>
。我需要MembershipFunction<T>*
在我的东西中有一个 s的向量IO
,还有一个std::map
from std::string
to MembershipFunction<T>*
。对我来说,用如此复杂的代码记住东西是不可能的。特别是在使用迭代器时。所以我尝试添加一些typedef
s 到IO
. 但听起来编译器无法看到嵌套模板。下面列出了错误。
我该怎么做才能克服?
#include <vector>
#include <map>
#include <string>
#include <utility>
#include "membership_function.h" // for the love of god!
// MembershipFunction is defined there!
#include "FFIS_global.h"
template <typename T>
class DLL_SHARED_EXPORT IO
{
private:
typedef std::pair<std::string, MembershipFunction<T>* > MapEntry; // (1)
typedef std::map<std::string, MembershipFunction<T>* > Map; // (2)
typedef std::vector<const MembershipFunction<T>* > Vector; // (3)
// And so on...
这些是错误:
(1) error: 'MembershipFunction' was not declared in this scope
(1) error: template argument 2 is invalid
(1) error: expected unqualified-id before '>' token
(2 and 3): same errors
编辑:
这是代码MembershipFunction
template <typename T>
class DLL_SHARED_EXPORT MembershipFunction
{
public:
virtual T value(const T& input) const{return T();}
virtual void setImplicationMethod(const typename MFIS<T>::Implication& method);
};