home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.lang.c++:12293 comp.object:3193 comp.databases:6085
- Newsgroups: comp.lang.c++,comp.object,comp.databases
- Path: sparky!uunet!munnari.oz.au!cs.mu.OZ.AU!mundil.cs.mu.OZ.AU!fjh
- From: fjh@mundil.cs.mu.OZ.AU (Fergus James HENDERSON)
- Subject: Re: A POET Tutorial
- Message-ID: <9222615.24974@mulga.cs.mu.OZ.AU>
- Keywords: OODBMS, C++, POET
- Sender: news@cs.mu.OZ.AU
- Organization: Computer Science, University of Melbourne, Australia
- References: <TCZ5DU@netmbx.netmbx.de>
- Date: Thu, 13 Aug 1992 05:05:46 GMT
- Lines: 53
-
- I have a couple of questions regarding Jonathan Robie's posting:
-
- ----------------------------------------------------------------------
-
- > main ()
- > {
- > PtBase objbase;
- >
- > objbase.Connect ("LOCAL"); // Connect to the server
- > objbase.Open ("test"); // Open the database
- >
- > Person *man = new Person(objbase);
- > man->Store();
- >
- > objbase.Close();
- > objbase.DisConnect();
- > delete man;
- > }
-
- Why aren't Close() and DisConnect() automatically called by the
- destructor?
-
- ----------------------------------------------------------------------
-
- > PersonAllSet* allPersons = new PersonAllSet("objbase");
- > Person* thisPerson;
- >
- > allPersons->Seek(0, PtSTART);
- > while (allPersons->Seek (1, PtCURRENT) == 0)
- > {
- > allPersons->Get(thisPerson);
- > thisPerson->DoSomething();
- > allPersons->Unget(thisPerson); // deletes the object if nobody
- > // else is using it.
- > }
- > delete allPersons;
- >
- >[...]
- >Note that we call Unget() when we are done with the object. Every
- >object you read takes up memory, so you should get into this habit.
-
- Again, weren't destructors invented so that we wouldn't have to rely
- on programmers habits?
-
- Also, is there any particular reason why allPersons is dynamically
- allocated in this example? Wouldn't it be simpler and more efficient
- to just use a local (automatic) variable?
-
- --
- Fergus Henderson fjh@munta.cs.mu.OZ.AU
- This .signature VIRUS is a self-referential statement that is true - but
- you will only be able to consistently believe it if you copy it to your own
- .signature file!
-