Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #7854
| From | Ian Collins <ian-news@hotmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: undefined reference to vtable |
| Date | 2011-07-16 11:35 +1200 |
| Message-ID | <98c18mFv3qU5@mid.individual.net> (permalink) |
| References | <7609b85f-04be-42c1-8aae-5daba6bdd1bc@f39g2000prb.googlegroups.com> |
On 07/16/11 11:05 AM, eric wrote:
> Dear Advanced C/g++ programers:
>
> a simple program about Creating an interface with an Abstract Base
> Class. from book (C++ cookbook) page 308, 309. Example 8-11. using a
> pure interface.
> ----------------------
> // Example 8-11 Using a pure interface
> class Person {
> public:
> virtual void eat() = 0;
> virtual void sleep() = 0;
> virtual void walk() = 0;
> virtual void jump() = 0;
> };
>
> class IAirbone {
> public:
> virtual void fly() = 0;
> virtual void up() = 0;
> virtual void down() = 0;
> };
>
> class Superhero : public Person, // A superhero *is* a person
> public IAirbone { // and flies
> public:
> virtual void eat();
> virtual void sleep();
> virtual void walk();
> virtual void jump();
> virtual void fly();
> virtual void up();
> virtual void down();
None of the above need the "virtual" key word.
> virtual ~Superhero();
Why have you given this a virtual destructor?
<snip>
> --------------------------------------------------
> actually that book even did not specially define Superhero::walk(),
> that is
> I add by myself to escape my compile's error(is that right? or book's
> is right?)
They must be defined.
--
Ian Collins
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
undefined reference to vtable eric <cneric12lin0@gmail.com> - 2011-07-15 16:05 -0700 Re: undefined reference to vtable Ian Collins <ian-news@hotmail.com> - 2011-07-16 11:35 +1200 Re: undefined reference to vtable Arvind <bharti.arvind@gmail.com> - 2011-07-15 20:49 -0700
csiph-web