home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12670 < prev    next >
Encoding:
Internet Message Format  |  1992-08-20  |  2.2 KB

  1. 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
  2. From: coates@newton.physics.uq.oz.au (Tony Coates)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: class used only once
  5. Message-ID: <BtAx8p.J7F@bunyip.cc.uq.oz.au>
  6. Date: 20 Aug 92 21:34:01 GMT
  7. References: <1992Aug20.171413.49157@evolving.com>
  8. Sender: news@bunyip.cc.uq.oz.au (USENET News System)
  9. Organization: Physics Dept. The University of Queensland
  10. Lines: 36
  11.  
  12. In article <1992Aug20.171413.49157@evolving.com>, dxs@evolving.com (Dan Stanger) writes:
  13. |> i am developing a program containing a set of routines and data
  14. |> where the data would have only one instance of it.  i am interested
  15. |> in comments regarding making it a class vs putting it in a seperate
  16. |> file and only exporting the routines that i need.
  17. |> any comments would be appreciated.
  18. |> thanks, dxs
  19.  
  20. Clearly, this is an area where declaring creating a class may not seem so necessary or
  21. useful, since using a separate file and exporting routines can still give you a well-defined
  22. interface and data-hiding (to some extent, at least).  I would nominate two advantages of
  23. using a class with just one instance:
  24.  
  25. (i) *better* data-hiding, though the usefulness of this depends on the (lack of) discipline
  26.     of the programmer
  27.  
  28. (ii) C++ handles the creation and destruction of objects itself - I have to write a lot of
  29.      programs in C, not C++, and while I use a pseudo-object-oriented style, whenever I have
  30.      data-structures to which I allocate memory at run-time, I have to explicitly call
  31.      creation and destruction routines.  I think that it is cleaner and more reliable to just
  32.      supply these routines and let the compiler decide when best to call them.
  33.  
  34.                                     Tony.
  35. _______________________________________________________________________________
  36.  
  37. A.B.Coates (Tony)
  38. Department of Physics
  39. The University of Queensland  QLD  4072
  40. Australia
  41.  
  42. Phone: (+617)365 3424           (Physics Departmental Office)
  43. Fax:   (+617)365 1242           (   "         "         "   )
  44. Email: coates@physics.uq.oz.au
  45.  
  46. "My messages mirror my feelings, but do not reflect University policy."
  47. _______________________________________________________________________________
  48.