home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / os / mswindo / programm / misc / 5456 < prev    next >
Encoding:
Text File  |  1993-01-28  |  1.5 KB  |  59 lines

  1. Newsgroups: comp.os.ms-windows.programmer.misc
  2. Path: sparky!uunet!inmos!fulcrum!bham!warwick!pavo.csi.cam.ac.uk!jca17
  3. From: jca17@phx.cam.ac.uk (J.C. Ashworth)
  4. Subject: (Borland?) C++ Language Question
  5. Message-ID: <1993Jan28.171855.10953@infodev.cam.ac.uk>
  6. Sender: jca17@cl.cam.ac.uk (J.C. Ashworth)
  7. Nntp-Posting-Host: farcet.cl.cam.ac.uk
  8. Organization: U of Cambridge Computer Lab, UK
  9. Date: Thu, 28 Jan 1993 17:18:55 GMT
  10. Lines: 47
  11.  
  12. I dunno whether this relates solely to the Borland C++ compiler or whether
  13. it's a general C++ feature / bug?
  14.  
  15. I seem to be able to do the following quite legally and with the expected
  16. result:
  17.  
  18. class B
  19. {
  20. // ...
  21. };
  22.  
  23. class C
  24. {
  25. // ...
  26. };
  27.  
  28. class D : public B
  29. {
  30.     int xtraField;
  31. // ...
  32. };
  33.  
  34. B& foo( ... );
  35.  
  36. D::func( ... )
  37. {
  38.     D& temp = (D&) foo( ... );
  39.     temp.xtraField = 5;
  40. }
  41.  
  42. Is this OK? How does the cast from B& to D& work? I suppose a cast from B& to C&
  43. would NOT be legal?
  44.  
  45. thanks.
  46.     
  47. -- 
  48.            ______________    _____________
  49.           /             /\  /            /\        Julian Ashworth
  50.          /_____    ____/ / /   _____    / /        Magdalene College
  51.           \___/   /\ __\/ /   /\___/   / /         Cambridge
  52.              /   / /     /   /_/__/   / /          England
  53.             /   / /     /            / /
  54.   __       /   / /     /   _____    / /            jca17@phx.cam.ac.uk
  55.  /  \_____/   / /     /   /\___/   / /
  56.  \           / /     /   / /  /   / /
  57.   \_________/ /     /___/ /  /___/ /    "It's a great way to steal a car
  58.    \________\/      \___\/   \___\/      but where do we get a jet-pac?"
  59.