home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- From: nikki@trmphrst.demon.co.uk (Nikki Locke)
- Path: sparky!uunet!pipex!demon!trmphrst.demon.co.uk!nikki
- Subject: Re: Calling pure virtual functions in base class constructor
- Reply-To: nikki@trmphrst.demon.co.uk
- Distribution: world
- X-Mailer: cppnews $Revision: 1.20 $
- Organization: Trumphurst Ltd.
- Lines: 39
- Date: Mon, 23 Nov 1992 11:55:58 +0000
- Message-ID: <722544958snx@trmphrst.demon.co.uk>
- Sender: usenet@gate.demon.co.uk
-
- In article <1992Nov20.184142.26362@taumet.com> steve@taumet.com (Steve Clamage) writes:
- > maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
- > | I suspect it is a quirk. To ban or not to ban a body for
- > |a pure virtual? Bjarne chose to allow them. I now see and accept that
- > |apart from some unrelated meaning for the body, some 'default' behaviour
- > |or, better, 'core' behaviour might well be a good use.
- >
- > Consider this: An abstract base class may have a pure virtual
- > destructor. The destructor for that base class will be called when
- > a derived object is destroyed. Therefore, you must provide a
- > definition for the pure virtual destructor.
- Aha, a man who knows ! That's that one explained entirely to my
- satisfaction.
-
- However, what I _really_ wanted to know is why, in a constructor or
- destructor, you still have to specify the scope override operator to call
- a pure virtual.
-
- Example :
-
- class A {
- public:
- A() {
- pure_virtual(); // undefined behaviour - WHY ?
- A::pure_vurtual(); // O.K.
- }
- virtual void pure_virtual() = 0;
- };
-
- void A::pure_virtual()
- {
- cout << "A::pure_virtual() called\n";
- }
-
- What is the logical reason for this, then ?
-
- --
- Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
- trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
-