home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!walter!porthos!delphinus!chw
- From: chw@bellcore.com (Charlie Woloszynski,MRE 2J-278,8295228,,27143)
- Subject: Question of scope
- Reply-To: chw@bellcore.com
- Organization: Bellcore
- Date: Fri, 22 Jan 93 18:45:58 GMT
- Message-ID: <1993Jan22.184558.21397@porthos.cc.bellcore.com>
- Sender: netnews@porthos.cc.bellcore.com (USENET System Software)
- Lines: 37
-
-
- A (novice) question about scope.
-
-
- I have a class Base from which I derive several additional classes, as in:
-
- class Base
- {
- virtual Draw();
- }
-
- class Derived1 : public Base
- {
- virtual Draw();
- }
-
- I need to pass a pointer to an instance of one of these derived classes
- to a function (so I can make use of the derived functions) like:
-
-
- void foo(Base *p)
- {
- p->Draw();
- }
-
- Now I generally need to create the Derived classes only to pass them
- to foo. I don't want these instances to exist after the call to foo.
-
- Anyway, does the following call the destructor just after returning
- from the foo?
-
- foo(& Derived1());
-
- Does it have any ugly portability problems?
-
- Charlie Woloszynski
- chw@bellcore.com
-