头文件中的错误C4430

时间:2014-07-30 13:09:58

标签: c++ warnings

错误C4430:缺少类型说明符 - 假设为int。注意:C ++不支持default-int

我有638个这样的错误,所以我知道这一切都是由一个错误造成的。我使用的这个代码使用VS6和VS7以及GCC完美地工作。将它迁移到VS2013会在这里和那里发生一些错误。我不知道为什么它会给我这个错误。我将发布一个代码块。如果您需要更多解释某件事,请告诉我。我尝试在互联网上查找,但看起来这个C4430出于各种原因。

许多人的第一个错误从第8行开始

// ----------------------------------------------------------------------------
//  vector-based database for fast O(1) lookups.
// ----------------------------------------------------------------------------
template< typename entity >
class VectorDatabase : public Database< entity, std::vector<entity> >
{
public:
    typedef std::vector<entity> container; //This is the first of many where the error is occuring
    typedef container::iterator iterator;

    bool isvalid( entityid p_id )
    {
        return p_id < m_container.size() && p_id != 0;
    }

    entity& get( entityid p_id )
    {
        if( p_id >= m_container.size() || p_id == 0 )
            throw Exception( "Out of bounds error in vector database" );

        if( m_container[p_id].ID() == 0 )
            throw Exception( "Invalid Item in vector database" );

        return m_container[p_id];
    }

    entity& create( entityid p_id )
    {
        if( m_container.size() <= p_id )
            m_container.resize( p_id + 1 );

        m_container[p_id].SetID( p_id );
        return m_container[p_id];
    }

    entityid findname( const std::string& p_name )
    {
        container::iterator itr = m_container.begin();
        stringmatchfull matcher( p_name );

        while( itr != m_container.end() )
        {
            if( matcher( itr->Name() ) )
                return itr->ID();
            ++itr;
        }
        return 0;
    }

};  // end class VectorDatabase

1 个答案:

答案 0 :(得分:2)

不确定这是否会产生错误,但首先您需要声明

typedef typename container::iterator iterator;

即,在声明中使用额外的typename,因为container是从属类型名称,请参阅Where and why do I have to put the "template" and "typename" keywords?

此外,entityid中的bool isvalid( entityid p_id )类型是否已在某处定义?