Re: why can't you initialize variable in case statements
Re: why can't you initialize variable in case statements
- Subject: Re: why can't you initialize variable in case statements
- From: Tom Saxton <email@hidden>
- Date: Wed, 21 Sep 2005 17:05:00 -0700
On 9/21/05, Scott Fraser <email@hidden> wrote:
> switch (someKey)
> {
> case 1:
> {
> someClassPointer myClassPointer = new
> someClassPointer(anInitialValue);
> myClassPointer->doesSomething();
> break;
> }
> case 2:
> {
> someOtherClass myOtherPointer = new someOtherClass(anInitialValue);
> myOtherPointer->doesSomethingElse();
> break;
> }
> }
>
> Now, each class instance goes out of scope (and its destructor is
> called) as it leaves the "case", rather than the "switch".
Actually, that's not correct. Destructors don't get called on object
pointers (created with "new") when they go out of scope. Objects yes,
pointers to objects no.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden