error LNK2019: unresolved external symbol

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I created a "Win 32 Project" with these three simple files, but when I
try to link, I get a LNK2019 error, I think it is a project setting,
but canone throw some light on this?

Thanks,
Bob

// FooBase.h

#ifndef _FooBase_h
#define _FooBase_h

class FooBase
{
public:
virtual ~FooBase();
virtual int GetNumber() = 0;

protected:
FooBase();
};

#endif _FooBase_h

// Foo.h

#ifndef _Foo_h
#define _Foo_h

#include "FooBase.h"

class Foo : virtual public FooBase
{
public:
Foo();
~Foo();
int GetNumber();
};

#endif _Foo_h

// Foo.cpp

#include "Foo.h"


Foo::Foo() : FooBase() {}

Foo::~Foo() {}

int Foo::GetNumber()
{
return 5;
}



Error 1 error LNK2019: unresolved external symbol "protected:
__thiscall FooBase::FooBase(void)" (??0FooBase@@IAE@XZ) referenced in
function "public: __thiscall Foo::Foo(void)" (??0Foo@@QAE@XZ) Foo.obj
Error 2 error LNK2019: unresolved external symbol "public: virtual
__thiscall FooBase::~FooBase(void)" (??1FooBase@@UAE@XZ) referenced in
function "public: void __thiscall Foo::`vbase destructor'(void)" (??
_DFoo@@QAEXXZ) Foo.obj
Error 3 fatal error LNK1120: 2 unresolved externals C:\scratch\Scratch
\Debug\CPP.dll

.



Relevant Pages

  • C++ design question
    ... to see if anyone can recommend a design improvement. ... fooBase has a reference to an object in fooDerived. ... int main ...
    (comp.object)
  • Re: error LNK2019: unresolved external symbol
    ... but canone throw some light on this? ... class FooBase ... You have declared FooBase constructor, ...
    (microsoft.public.vc.language)