home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11868 < prev    next >
Encoding:
Text File  |  1992-07-31  |  1.2 KB  |  38 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. Distribution: world
  5. Subject: Re: run-time type checking)
  6. References: <TMB.92Jul29125322@arolla.idiap.ch>
  7. X-Mailer: cppnews $Revision: 1.10 $
  8. Organization: Trumphurst Ltd.
  9. Lines: 24
  10. Date: Fri, 31 Jul 1992 11:33:16 +0000
  11. Message-ID: <712607596snx@trmphrst.demon.co.uk>
  12. Sender: usenet@gate.demon.co.uk
  13.  
  14.  
  15. In article <TMB.92Jul29125322@arolla.idiap.ch> tmb@idiap.ch writes:
  16. > It would, in fact, be nice if C++ had a tagged union type, like Pascal
  17. > or SML. Something along the lines of:
  18. > union hetero int {
  19. > case 1: type1 *p1;
  20. > case 2: type2 *p2;
  21. > };
  22. > int f(hetero h) {
  23. >     switch(h) {
  24. >     case 1: return h.p1->foo();
  25. >     case 2: return h.p2->bar();
  26. >     }
  27. > }
  28. **** YEEEUUUURRRGGGGHHHH *****
  29. Surely this is what virtual functions are for.
  30. ---
  31. Nikki Locke              |                        | nikki@trmphrst.demon.co.uk
  32. Trumphurst Ltd.          | Tel: +44 (0)691-670318 | nikki@cix.compulink.co.uk
  33. PC and Unix consultancy  | Fax: +44 (0)691-670316 | nikki@kewill.co.uk
  34. trmphrst.demon.co.uk is NOT connected with ANY other sites at demon.co.uk.
  35. Demon.co.uk is a dial-up subscription access point to the Internet.
  36.