unresolved external symbol

Z

Zoran Stipanicev

When I try to build the code below I get the error:

main.obj : error LNK2019: unresolved external symbol "class NS::DerA __cdecl
NS::eek:perator+(class NS::DerB,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;
}
 
V

Victor Bazarov

Zoran said:
When I try to build the code below I get the error:

main.obj : error LNK2019: unresolved external symbol "class NS::DerA __cdecl
NS::eek:perator+(class NS::DerB,class NS::Base const &)"
(??HNS@@YA?AVDerA@0@VDerB@0@ABVBase@0@@Z) referenced in function _main

[..]

Make sure you link together _all_ files in your project. Seek help from
microsoft.public.vc.ide_general or microsoft.public.vc.project_mgt for
more information on it. I fixed the syntax omissions in your code, put
it all in one file, and it compiled/linked fine with VC++ 2005.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top