C ++:错误“......不是从类型派生出来的......”

时间:2010-09-19 15:51:32

标签: c++ compiler-errors

template<typename T1, typename T2>
class Bimap {
public:
    class Data;
    typedef Data* DataP;    
    typedef std::multimap<T1, DataP> T1Map;
    typedef std::multimap<T2, DataP> T2Map;

    class Data {
    private:
        Bimap& bimap;
        T1Map::iterator it1;
        /*...*/
    };
};

这给了我这个编译错误:

error: type 'std::multimap<T1, Bimap<T1, T2>::Data*, std::less<_Key>, std::allocator<std::pair<const T1, Bimap<T1, T2>::Data*> > >' is not derived from type 'Bimap<T1, T2>::Data'

这是什么意思?这有什么问题?

1 个答案:

答案 0 :(得分:15)

制作:

typename T1Map::iterator it1;

http://www.parashift.com/c++-faq-lite/templates.html#faq-35.18