home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / cplus / 16788 < prev    next >
Encoding:
Text File  |  1992-11-23  |  1.7 KB  |  53 lines

  1. Newsgroups: comp.lang.c++
  2. From: nikki@trmphrst.demon.co.uk (Nikki Locke)
  3. Path: sparky!uunet!pipex!demon!trmphrst.demon.co.uk!nikki
  4. Subject: Re: Calling pure virtual functions in base class constructor
  5. Reply-To: nikki@trmphrst.demon.co.uk
  6. Distribution: world
  7. X-Mailer: cppnews $Revision: 1.20 $
  8. Organization: Trumphurst Ltd.
  9. Lines: 39
  10. Date: Mon, 23 Nov 1992 11:55:58 +0000
  11. Message-ID: <722544958snx@trmphrst.demon.co.uk>
  12. Sender: usenet@gate.demon.co.uk
  13.  
  14. In article <1992Nov20.184142.26362@taumet.com> steve@taumet.com (Steve Clamage) writes:
  15. > maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
  16. > |    I suspect it is a quirk. To ban or not to ban a body for
  17. > |a pure virtual? Bjarne chose to allow them. I now see and accept that
  18. > |apart from some unrelated meaning for the body, some 'default' behaviour
  19. > |or, better, 'core' behaviour might well be a good use.
  20. > Consider this:  An abstract base class may have a pure virtual
  21. > destructor.  The destructor for that base class will be called when
  22. > a derived object is destroyed.  Therefore, you must provide a
  23. > definition for the pure virtual destructor.
  24. Aha, a man who knows ! That's that one explained entirely to my 
  25. satisfaction. 
  26.  
  27. However, what I _really_ wanted to know is why, in a constructor or
  28. destructor, you still have to specify the scope override operator to call 
  29. a pure virtual.
  30.  
  31. Example :
  32.  
  33. class A {
  34. public:
  35.     A() { 
  36.         pure_virtual();        // undefined behaviour - WHY ?
  37.         A::pure_vurtual();    // O.K.
  38.         }
  39.     virtual void pure_virtual() = 0;
  40.     };
  41.  
  42. void A::pure_virtual()
  43. {
  44.     cout << "A::pure_virtual() called\n";
  45. }
  46.  
  47. What is the logical reason for this, then ?
  48.  
  49. -- 
  50. Nikki Locke,Trumphurst Ltd.(PC and Unix consultancy) nikki@trmphrst.demon.co.uk
  51. trmphrst.demon.co.uk is NOT affiliated with ANY other sites at demon.co.uk.
  52.