gpt4 book ai didi

c++(构造函数)继承-LNK 2019错误

转载 作者:行者123 更新时间:2023-11-30 04:22:52 28 4
gpt4 key购买 nike

<分区>

Possible Duplicate:
What is an undefined reference/unresolved external symbol error and how do I fix it?

我有一个涉及类 A 及其派生类 B 的 LNK 错误。更准确地说,我有这个编译错误

Error   239 error LNK2019: unresolved external symbol "public: virtual __thiscall A::~A(void)" (??1A@@UAE@XZ) referenced in function "public: virtual __thiscall B::~B(void)" (??1B@@UAE@XZ)    D:\Products\path\file.lib(B.obj)
Error 240 error LNK2019: unresolved external symbol "public: __thiscall A::A(void)" (??A@@QAE@XZ) referenced in function "public: __thiscall B::B(void)" (??B@@QAE@XZ) D:\Products\path\file.lib(B.obj)
Error 241 error LNK2019: unresolved external symbol "public: void __thiscall A::function(float * *,float * *,float * *,float * *,int)" (?function@A@@QAEXPAPAM000H@Z) referenced in function "public: class SomeType* __thiscall B::function_bis(void)" (?function_bis@B@@QAEPAVSomeType@@XZ) D:\Products\path\file.lib(B.obj)

我猜这可能与继承构造函数的调用有关,或者在 function() 或 function_bis() 的某些调用中不遵守签名。但是,我找不到这样的错误。

您是否有可能解决问题的提示?这是(简化的)A 和 B 的代码。

B.cpp

B::B(void)
{
}

B::B(Type1* d1, Type1* d2, Type1* r):A()
{
D1= d1;
D2= d2;
R= r;
}


B::~B( void )
{
}

SomeType* B::function()
{
// do things
function_bis() ;
}

B.h

class B:
public A
{
public:

B(void) ;
B(Type1* , Type1* , Type1* );
virtual ~B(void);

SomeType* function() ;

private:

Type1* D1;
Type1* D2;
Type1* R;

};

A.cpp

using namespace std ;

A::A(void){}

A::~A(void){}

void A::function_bis(float** d, float** d2, float** d3, float** d4, int n)
{}

A.h

class A
{

public:
A(void);
virtual ~A(void);

void function_bis(float** , float** , float** , float** , int );

};

谢谢!

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com