Z
Zoran Stipanicev
When I try to build the code below I get the error:
main.obj : error LNK2019: unresolved external symbol "class NS:erA __cdecl
NS:perator+(class NS:erB,class NS::Base const &)"
(??HNS@@YA?AVDerA@0@VDerB@0@ABVBase@0@@Z) referenced in function _main
I'm using VS2005, and I have no idea how to fix this error. I' tried to
define
the operator in DerB.h (with including DerA.h) and it didn't solve the
problem.
Any Ideas?
Thx!
/** Base.h **/
namespace NS
{
class Base{...}
}
/************/
/** DerA.h **/
namespace NS
{
class DerA : public Base{...}
}
/************/
/** DerB.h **/
namespace NS
{
class DerB : public Base{...}
class DerA;
DerA operator + (const DerB& lhs, const Base& rhs);
}
/************/
/** DerB.cpp **/
#include "DerA.h"
namespace NS
{
DerA operator + (const DerB& lhs, const Base& rhs)
{...}
}
/**************/
/** main.cpp **/
#include ...
using namespace NS;
main
{
DerA a;
DerB b;
DerC c; //defined same as DerA and DerB
a = b + c;
}
main.obj : error LNK2019: unresolved external symbol "class NS:erA __cdecl
NS:perator+(class NS:erB,class NS::Base const &)"
(??HNS@@YA?AVDerA@0@VDerB@0@ABVBase@0@@Z) referenced in function _main
I'm using VS2005, and I have no idea how to fix this error. I' tried to
define
the operator in DerB.h (with including DerA.h) and it didn't solve the
problem.
Any Ideas?
Thx!
/** Base.h **/
namespace NS
{
class Base{...}
}
/************/
/** DerA.h **/
namespace NS
{
class DerA : public Base{...}
}
/************/
/** DerB.h **/
namespace NS
{
class DerB : public Base{...}
class DerA;
DerA operator + (const DerB& lhs, const Base& rhs);
}
/************/
/** DerB.cpp **/
#include "DerA.h"
namespace NS
{
DerA operator + (const DerB& lhs, const Base& rhs)
{...}
}
/**************/
/** main.cpp **/
#include ...
using namespace NS;
main
{
DerA a;
DerB b;
DerC c; //defined same as DerA and DerB
a = b + c;
}