home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!kithrup!stanford.edu!ames!elroy.jpl.nasa.gov!swrinde!mips!mips!munnari.oz.au!bunyip.cc.uq.oz.au!newton.physics.uq.oz.au!coates
- From: coates@newton.physics.uq.oz.au (Tony Coates)
- Newsgroups: comp.lang.c++
- Subject: Re: class used only once
- Message-ID: <BtAx8p.J7F@bunyip.cc.uq.oz.au>
- Date: 20 Aug 92 21:34:01 GMT
- References: <1992Aug20.171413.49157@evolving.com>
- Sender: news@bunyip.cc.uq.oz.au (USENET News System)
- Organization: Physics Dept. The University of Queensland
- Lines: 36
-
- In article <1992Aug20.171413.49157@evolving.com>, dxs@evolving.com (Dan Stanger) writes:
- |> i am developing a program containing a set of routines and data
- |> where the data would have only one instance of it. i am interested
- |> in comments regarding making it a class vs putting it in a seperate
- |> file and only exporting the routines that i need.
- |> any comments would be appreciated.
- |> thanks, dxs
-
- Clearly, this is an area where declaring creating a class may not seem so necessary or
- useful, since using a separate file and exporting routines can still give you a well-defined
- interface and data-hiding (to some extent, at least). I would nominate two advantages of
- using a class with just one instance:
-
- (i) *better* data-hiding, though the usefulness of this depends on the (lack of) discipline
- of the programmer
-
- (ii) C++ handles the creation and destruction of objects itself - I have to write a lot of
- programs in C, not C++, and while I use a pseudo-object-oriented style, whenever I have
- data-structures to which I allocate memory at run-time, I have to explicitly call
- creation and destruction routines. I think that it is cleaner and more reliable to just
- supply these routines and let the compiler decide when best to call them.
-
- Tony.
- _______________________________________________________________________________
-
- A.B.Coates (Tony)
- Department of Physics
- The University of Queensland QLD 4072
- Australia
-
- Phone: (+617)365 3424 (Physics Departmental Office)
- Fax: (+617)365 1242 ( " " " )
- Email: coates@physics.uq.oz.au
-
- "My messages mirror my feelings, but do not reflect University policy."
- _______________________________________________________________________________
-