Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #7854

Re: undefined reference to vtable

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From Ian Collins <ian-news@hotmail.com>
Newsgroups comp.lang.c++
Subject Re: undefined reference to vtable
Date Sat, 16 Jul 2011 11:35:52 +1200
Lines 52
Message-ID <98c18mFv3qU5@mid.individual.net> (permalink)
References <7609b85f-04be-42c1-8aae-5daba6bdd1bc@f39g2000prb.googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
X-Trace individual.net U3+KVaiY+EWKcOZY7/i1TQDv7lL7/Hg/A6ldaZ0g6JrPA74L1d
Cancel-Lock sha1:6QOEKMmm+WcaGlX+q/opLPzk1i0=
User-Agent Mozilla/5.0 (X11; U; SunOS i86pc; en-US; rv:1.9.2.9) Gecko/20101021 Lightning/1.0b2 Thunderbird/3.1.4
In-Reply-To <7609b85f-04be-42c1-8aae-5daba6bdd1bc@f39g2000prb.googlegroups.com>
Xref x330-a1.tempe.blueboxinc.net comp.lang.c++:7854

Show key headers only | View raw


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


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