链接者抱怨“未解决的外部符号”

时间:2012-02-11 13:32:45

标签: c++ linker-errors

这是头文件代码

#ifndef SEQUENCE_H
#define SEQUENCE_H
#include <cstdlib>  // Provides size_t

namespace CISP430_A2
{
    class sequence
    {
    public:
        // TYPEDEFS and MEMBER CONSTANTS
        typedef double value_type;
        typedef size_t size_type;
        enum { CAPACITY = 30 };
        // CONSTRUCTOR
        sequence(size_type entry=CAPACITY )
        {
            for(int i=0;i<CAPACITY;i++)
                data[i]=0;
            used=0;
            capacity=CAPACITY;
            current_index=0;
        }
           // COPY CONSTRUCTOR
        sequence(const sequence& entry);       
    // Library facilities used: cstdlib
        // MODIFICATION MEMBER FUNCTIONS
        void start( );
        void advance( );
        void insert(const value_type& entry);
        void attach(const value_type& entry);
        void remove_current( );
        void resize(size_type new_capacity);
        void sequence::operator =(const sequence& entry);
        // CONSTANT MEMBER FUNCTIONS
        size_type size( ) const;
        bool is_item( ) const;
        value_type current( ) const;
        //Destructor
         ~sequence(){}
    private:
        value_type data[CAPACITY];
        size_type used;
        size_type capacity;
        size_type current_index;
    };
}

#endif

我目前收到此链接器错误:

  

sequence_test.obj:错误LNK2019:函数public: __thiscall CISP430_A2::sequence::sequence(unsigned int)中引用的未解析的外部符号“_main”(?? 0序列@ CISP430_A2 @@ QAE @ I @ Z)

1 个答案:

答案 0 :(得分:0)

我只是成功地尝试并编译了你的文件,因此它不在你的代码中(至少不在你发布的部分中)

我想,您正在使用Visual Studio?请尝试以下

  • 确保您的项目设置正确(项目中包含的所有文件?)
  • 您是否使用预编译的标头?试着把它们关掉。
  • 尝试干净的重建。