Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!uunet!tut.cis.ohio-state.edu!ucsd!helios.ee.lbl.gov!ux1.lbl.gov!beard From: beard@ux1.lbl.gov (Patrick C Beard) Newsgroups: comp.lang.c++ Subject: Re: anonymous variables Message-ID: <5556@helios.ee.lbl.gov> Date: 6 May 90 19:01:27 GMT References: <351@dyndata.UUCP> <139@logo.procase.UUCP> Sender: usenet@helios.ee.lbl.gov Reply-To: beard@ux1.lbl.gov (Patrick C Beard) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 20 X-Local-Date: 6 May 90 12:01:27 PDT In article <139@logo.procase.UUCP> roger@procase.UUCP (Roger H. Scott) writes: #In article <351@dyndata.UUCP> dan@dyndata.UUCP (Dan Everhart) writes: #>It might be neat to be able to define objects anonymously ... #Not only *might* it be neat, it *is* neat: # SomeClass(); #constructs an anonymous instance of class SomeClass and the immediately proceeds #to destroy it. You were warm. Yes, I tried it, and it does work. Where is this documented? This still has the semantics of a function call however, and one could just as easily write a routine that has static data and call that. And another point, your message implies that the object is immediately destroyed. The original poster was using the fact that the destructor would get called at the end of the scope. I see that as an advantage. ------------------------------------------------------------------------------- - Patrick Beard, Macintosh Programmer (beard@lbl.gov) - - Berkeley Systems, Inc. "..............Good day!" - Paul Harvey - -------------------------------------------------------------------------------