链接器抱怨“无法解析的外部符号”;

发布于 2025-01-04 14:37:56 字数 1830 浏览 0 评论 0原文

头文件代码

#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)” (??0sequence@CISP430_A2@@QAE@I@Z)在函数 _main

中引用

This is the header file code

#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

I am currently getting this linker error:

sequence_test.obj : error LNK2019: unresolved external symbol "public: __thiscall CISP430_A2::sequence::sequence(unsigned int)" (??0sequence@CISP430_A2@@QAE@I@Z) referenced in function _main

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

獨角戲 2025-01-11 14:37:56

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

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

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

I just tried and compiled your files sucessfully, so it's not in your code (at least not in the parts you posted)

I suppose, you're using Visual Studio? Try the following

  • Make sure your project settings are correct (all files included in your project?)
  • Do you use precompiled headers? Try to turn them off.
  • Try a clean rebuild.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文