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)
|