unresolved external symbol

Discussion in 'C++' started by Zoran Stipanicev, Jan 11, 2006.

  1. 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;
    }



    ---
    Best regards,
    Stipanicev.
     
    Zoran Stipanicev, Jan 11, 2006
    #1
    1. Advertising

  2. Zoran Stipanicev wrote:
    > 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
     
    Victor Bazarov, Jan 11, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Harrison
    Replies:
    0
    Views:
    1,079
    John Harrison
    Jul 20, 2003
  2. Izak Pretorius
    Replies:
    2
    Views:
    1,633
    Christopher
    Sep 14, 2003
  3. Rodolphe
    Replies:
    4
    Views:
    1,131
    Rodolphe
    Oct 3, 2003
  4. mp
    Replies:
    2
    Views:
    6,989
  5. Scott Allen
    Replies:
    8
    Views:
    11,056
    Scott Allen
    May 2, 2004
Loading...

Share This Page