home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11495 < prev    next >
Encoding:
Text File  |  1992-07-25  |  1.5 KB  |  48 lines

  1. Path: sparky!uunet!pipex!slxsys!xon!michael
  2. From: michael@xon.co.uk (Michael J Marshall)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: template argument as base class
  5. Message-ID: <1238@dorothy.xon.co.uk>
  6. Date: 24 Jul 92 10:39:44 GMT
  7. References: <20204@sbsvax.cs.uni-sb.de>
  8. Organization: X-ON Software - London, England
  9. Lines: 36
  10. X-Newsreader: Tin 1.1 PL4
  11.  
  12. stefan@mpi-sb.mpg.de (Stefan Naeher) writes:
  13. : Does anyone know a workaround for the following problem.
  14. : ...
  15. : A possible application is the implementation of data types with implementation 
  16. : parameters, e.g., dictionary<skiplist>, dictionary<red_black_tree>, ....
  17.  
  18. Perhaps try something like:
  19.  
  20. template <class T> class container
  21. {
  22. private:
  23.     T data;
  24. public:
  25.     ....
  26. };
  27.  
  28. This should give you the implementation control you are seeking. I can see
  29. interfacing issues being a problem - you will need to ensure that the
  30. interfaces to the classes used as T in the template are similar (if not
  31. identical) or you're going to have trouble.
  32.  
  33. FYI, Borland's 3.x C++ products have a class library with template
  34. implementations that do what you want. If you want me to post some details
  35. on the net, e-mail me, and I'll post an article on how they go about it.
  36. Warning: it's NOT trivial!
  37.  
  38. My 2p worth
  39.  
  40. Michael
  41.  
  42. = Michael John Marshall - michael@xon.co.uk = B0ftg+k-s(+)h-r-
  43. =   X-ON Software - 21 Great Tower St, London EC3R 5AQ ENGLAND
  44. =   H 071 281 7056 - W 071 522 0088
  45. = Last night I played poker with a deck of Tarot cards -
  46. = I got a full house and four people died - Steven Wright
  47.