home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #26 / NN_1992_26.iso / spool / comp / lang / cplus / 15894 < prev    next >
Encoding:
Text File  |  1992-11-08  |  1.7 KB  |  44 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!rational.com!thor!rmartin
  3. From: rmartin@thor.Rational.COM (Bob Martin)
  4. Subject: Re: What is wrong with it?
  5. Message-ID: <rmartin.721098086@thor>
  6. Sender: news@rational.com
  7. Organization: Rational
  8. References: <1992Oct31.203619.13669@cs.tu-berlin.de>
  9. Date: Sat, 7 Nov 1992 01:01:26 GMT
  10. Lines: 32
  11.  
  12. oertelh@cs.tu-berlin.de (Helmut Oertel) writes:
  13.  
  14. |LOOKING FOR C++ EXPERTS,
  15.  
  16. |Description of Problems see below
  17.  
  18. |Program-Example Part One (without multiple inheritance and virtual base-classes):
  19.  
  20. [simple single inheritance example which did downcasting]
  21.  
  22. |Program-Example Part Two (using multiple inheritance and virtual base-classes): where┤s the error?
  23.  
  24. [simple example using multiple virtual inheritance, and attempted to
  25. downcast from a virtual vase]
  26.  
  27. |The first program-example yields the desired output ("ok") while the second one usually shuts down without any warning message. The questions is: ist there an error in the program itself or does my compiler (BORLAND C++ 3.1) have problems with virtual baseclasses and multiple inheritance.
  28. |I am grateful for any comment (how can one solve this Problem, do other C++ compilers have similar problems, and so on..)
  29.  
  30. |
  31.  
  32. This is a problem in your code.  It is illegal to cast a virtual base
  33. class into a derived class.  This is specified in the ARM 10.6c.  The
  34. reason is that the virtual base class has no way of knowing the memory
  35. layout of the derived object.  Therefore it cannot find the beginning
  36. address of the derived object.
  37.  
  38.  
  39. --
  40. Robert Martin                        Training courses offered in:
  41. R. C. M. Consulting                       Object Oriented Analysis
  42. 2080 Cranbrook Rd.                        Object Oriented Design
  43. Green Oaks, Il 60048 (708) 918-1004       C++
  44.