链接器抱怨“无法解析的外部符号”;
sequence_test.cpp
的完整代码(测试调试器驱动程序)sequence2.cpp
的完整代码(实现文件)
头文件代码
#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
Full code of
sequence_test.cpp
(test debugger driver)Full code of
sequence2.cpp
(implementation file)
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我刚刚尝试并成功编译了您的文件,因此它不在您的代码中(至少不在您发布的部分中)
我想,您正在使用 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