home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11548 < prev    next >
Encoding:
Internet Message Format  |  1992-07-25  |  1.3 KB

  1. Xref: sparky comp.lang.c++:11548 comp.std.c++:959
  2. Newsgroups: comp.lang.c++,comp.std.c++
  3. Path: sparky!uunet!cs.utexas.edu!torn!watserv1!watmath!watcgl!rhbartel
  4. From: rhbartel@watcgl.waterloo.edu (Richard Bartels)
  5. Subject: Re: run-time type checking (was: Re: Covariant Types in Derived Classes)
  6. Message-ID: <BryL9q.K5I@watcgl.waterloo.edu>
  7. Organization: Computer Graphics Laboratory, University of Waterloo, Ontario, Canada
  8. References: <1992Jul24.143359.3602@advtech.uswest.com> <1992Jul24.234628.21196@cadsun.corp.mot.com> <1992Jul25.172045.24675@ucc.su.OZ.AU>
  9. Date: Sat, 25 Jul 1992 19:10:38 GMT
  10. Lines: 21
  11.  
  12. As long as the downcasting discussion is open again,
  13. the example we are confronting which requires something like
  14. that, we think, is the issue of input from disk.
  15.  
  16. I would love to have a solution that did not require the cop-out of
  17. isA() and cast/convert.
  18.  
  19. Consider the classic "List" class and "ListNode" class.
  20. ListNode is a base class, and assume there are two flavors
  21. of derived node.  We write a List that contains a mix of
  22. these nodes out to a file; now we want to read the List back
  23. in and reconstruct it.
  24.  
  25. Can it be done without resorting to an isA() member function,
  26. some member data to identify node type, and possibly some
  27. casting/conversion?
  28.  
  29. What's the authoritative answer?
  30.  
  31. -Richard
  32.  
  33.