home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / cplus / 19823 < prev    next >
Encoding:
Internet Message Format  |  1993-01-24  |  1.8 KB

  1. Path: sparky!uunet!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!ira.uka.de!Germany.EU.net!urmel.informatik.rwth-aachen.de!tabaqui!dak
  2. From: dak@tabaqui.informatik.rwth-aachen.de (David Kastrup)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Is this C++ advice from an OO book true? (beginner question)
  5. Date: 24 Jan 93 10:11:42 GMT
  6. Organization: Rechnerbetrieb Informatik - RWTH Aachen
  7. Lines: 27
  8. Distribution: world
  9. Message-ID: <dak.727870302@tabaqui>
  10. References: <sherman.727849469@foster>
  11. NNTP-Posting-Host: tabaqui.informatik.rwth-aachen.de
  12.  
  13. sherman@unx.sas.com (Chris Sherman) writes:
  14.  
  15. >I don't understand one of the book's recommendations:
  16.  
  17. >  11.  Call virtual class constructors in dervied class constructors.
  18.  
  19. >     I pity the poor fools who have to spend nights and weekends searching
  20. >     for the reason that a class variable occasionally takes on strange,
  21. >     unexpected values .  .  .  only to find through their bleary eyes
  22. >     that they forgot to allocate space for a virtual base (super) class,
  23. >     so that storage is allocated for the base class's members.  Even if
  24. >     the class has no members, declare it--you never know what future
  25. >     changes will come back to haunt you (or the person who inherits your
  26. >     mine field)!
  27.  
  28.  
  29. >Or if this is very good advice, could someone give an example showing why
  30. >it is true?
  31.  
  32. >This is a beginner question obviously--thanx for any help!
  33.  
  34. And the above book writes a beginner's answer. Constructors cannot be
  35. virtual and I pity the poor fools who have to spend nights and weekends
  36. only to find out that in C++ the type system is static, and so every
  37. object's type is fixed from the beginning and types are managed by
  38. the compiler. If the runtime had anything to do with the type system in
  39. C++, maybe there would be such a thing as a virtual constructor.
  40.