TIP: Click on subject to list as thread! ANSI
echo: c_plusplus
to: KEN WAUGH
from: SUNIR SHAH
date: 1997-07-22 00:27:00
subject: Re: Sunir ventures into

To: Ken Waugh
Subject: Re: Sunir ventures into C
 SS> /* 1. Passing by reference */
 SS> void foo( int& HeyIMagicallyAlterYourVariableWithoutTellingYou )
 SS> {
 KW> You aren't gonna like this one bit then... What you mention above pass
 KW> by  reference, I posted a C example of it happening just this week.
Yes, but that requires an explicit cast or operation on the caller's side
so it isn't invisible.  By modifying the caller's variables without her
permission, the side effects could be disastrous.
Say...
    CFoo *pFoo = new CFoo;
    ...
    EvilFooFunc( pFoo );
    pFoo->member = ;
void EvilFooFunc( CFoo* &pFoo )
{
    delete pFoo;
}
Can you say memory leak?
SS
--- Maximus 3.01
---------------
* Origin: BitByters BBS, Rockland ON, Can. (613)446-7773 v34, (1:163/215)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.