Re: Inheritance and polymorphism


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]

Posted by Graham Smith on April 19, 2001 at 20:53:44:

In Reply to: Re: Inheritance and polymorphism posted by Nathan on April 19, 2001 at 19:52:59:

: Right but lets say I have class Base with a virtual function. Then I have another class Derived with that same virtual function. I don't want to actually implement it there, I just want to "set it up". I have another class Double_Derived from Derived, and that is where I want to implement my virtual function. The problem I am having is that the compiler looks for implementation in Derived and doesn't bother checking Double_Derived even though is publicly inherited from Derived. This throws a link error 2001...

: Animal.obj : error LNK2001: unresolved external symbol "public: virtual void __thiscall Animal::Tick(void)" (?Tick@Animal@@UAEXXZ)


It doesn't matter what code you put in Animal::Tick() in your Derived class, because you are over-riding it in your Double_Derived class. You could just make it an inline function in your Derived.h, with a one line return statement. That worked for me.



Follow Ups:



Post a Followup

Name:
E-Mail:

Subject:

Comments:

Optional Link URL:
Link Title:
Optional Image URL:


[ Follow Ups ] [ Post Followup ] [ CS2704 Web Discussion Board ] [ FAQ ]