home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11352 < prev    next >
Encoding:
Text File  |  1992-07-22  |  978 b   |  39 lines

  1. Newsgroups: comp.lang.c++
  2. Path: sparky!uunet!taumet!steve
  3. From: steve@taumet.com (Steve Clamage)
  4. Subject: Re: Conversion operators and typedef names
  5. Message-ID: <1992Jul22.221618.12782@taumet.com>
  6. Keywords: Microsoft C++ new error bug
  7. Organization: TauMetric Corporation
  8. References: <1992Jul21.132931.8728@ohm.york.ac.uk> <1992Jul21.160917.27353@wam.umd.edu>
  9. Date: Wed, 22 Jul 1992 22:16:18 GMT
  10. Lines: 27
  11.  
  12. krc@wam.umd.edu (Kevin R. Coombes) writes:
  13.  
  14. >... a conversion operator to a typedef name ...  should you do it?
  15.  
  16. >class MyTime {
  17. >  ...
  18. >  operator time_t(void);   // Does this make you queasy?
  19. >  ...
  20. >};
  21.  
  22. If the conversion operator does not make any assumptions about the
  23. actual type of time_t it should be perfectly OK.
  24.  
  25. Example:
  26.  
  27.     #include <time.h>
  28.  
  29.     class MyTime {
  30.         struct tm t;    // the broken-down time
  31.     public:
  32.         operator time_t() { return ::mktime(&t); }
  33.         ...
  34.     };
  35. -- 
  36.  
  37. Steve Clamage, TauMetric Corp, steve@taumet.com
  38. Vice Chair, ANSI C++ Committee, X3J16
  39.