home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!taumet!steve
- From: steve@taumet.com (Steve Clamage)
- Subject: Re: Conversion operators and typedef names
- Message-ID: <1992Jul22.221618.12782@taumet.com>
- Keywords: Microsoft C++ new error bug
- Organization: TauMetric Corporation
- References: <1992Jul21.132931.8728@ohm.york.ac.uk> <1992Jul21.160917.27353@wam.umd.edu>
- Date: Wed, 22 Jul 1992 22:16:18 GMT
- Lines: 27
-
- krc@wam.umd.edu (Kevin R. Coombes) writes:
-
- >... a conversion operator to a typedef name ... should you do it?
-
- >class MyTime {
- > ...
- > operator time_t(void); // Does this make you queasy?
- > ...
- >};
-
- If the conversion operator does not make any assumptions about the
- actual type of time_t it should be perfectly OK.
-
- Example:
-
- #include <time.h>
-
- class MyTime {
- struct tm t; // the broken-down time
- public:
- operator time_t() { return ::mktime(&t); }
- ...
- };
- --
-
- Steve Clamage, TauMetric Corp, steve@taumet.com
- Vice Chair, ANSI C++ Committee, X3J16
-