home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!news.univie.ac.at!scsing.switch.ch!univ-lyon1.fr!ghost.dsi.unimi.it!batcomputer!munnari.oz.au!metro!extro.ucc.su.OZ.AU!maxtal
- From: maxtal@extro.ucc.su.OZ.AU (John MAX Skaller)
- Subject: Re: Question of scope
- Message-ID: <1993Jan27.153140.21532@ucc.su.OZ.AU>
- Sender: news@ucc.su.OZ.AU
- Nntp-Posting-Host: extro.ucc.su.oz.au
- Organization: MAXTAL P/L C/- University Computing Centre, Sydney
- References: <1993Jan22.184558.21397@porthos.cc.bellcore.com>
- Date: Wed, 27 Jan 1993 15:31:40 GMT
- Lines: 41
-
- In article <1993Jan22.184558.21397@porthos.cc.bellcore.com> chw@bellcore.com writes:
- >
- >A (novice) question about scope.
-
- Not a novice question! One thats got the committee
- stumped.
- >
- >void foo(Base *p)
- >{
- > p->Draw();
- >}
- >
- >Anyway, does the following call the destructor just after returning
- >from the foo?
- >
- > foo(& Derived1());
- >
- >Does it have any ugly portability problems?
-
- Yes. The lifetime of temporary objects is not well
- defined yet. The code
-
- void foo(const Base &b)
- {
- b.Draw();
- }
-
- is safer since any compiler that deleted the temporary argument
-
- foo(Derived1());
-
- would invalidate a lot of code. But even this is not
- yet guarranteed to be safe (although it probably will be
- in the Standard).
-
-
- --
- ;----------------------------------------------------------------------
- JOHN (MAX) SKALLER, maxtal@extro.ucc.su.oz.au
- Maxtal Pty Ltd, 6 MacKay St ASHFIELD, NSW 2131, AUSTRALIA
- ;------ SCIENTIFIC AND ENGINEERING SOFTWARE ---ph: 2 799 8223 --------
-