Gmail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Goto case?
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  6 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Paul N  
View profile  
 More options Nov 3, 10:03 am
Newsgroups: comp.lang.c++
From: Paul N <gw7...@aol.com>
Date: Mon, 2 Nov 2009 14:33:55 -0800 (PST)
Local: Tues, Nov 3 2009 10:03 am
Subject: Goto case?
If I'm within a switch, then saying "case 10:" creates a sort of
label. Is it possible to jump directly to one of these, eg "goto case
12;"? I realise this can be done by adding a "normal" label next to
the "case" label, and that it might be possible to arrange a similar
thing by cunning use of fall-through or by changing the variable and
executing the switch again, but is there a neat syntax to jump to one
of the other cases?

Thanks.
Paul.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
siddhant3s  
View profile  
 More options Nov 3, 10:15 am
Newsgroups: comp.lang.c++
From: siddhant3s <siddhan...@gmail.com>
Date: Mon, 2 Nov 2009 14:45:31 -0800 (PST)
Local: Tues, Nov 3 2009 10:15 am
Subject: Re: Goto case?
On Nov 3, 3:33 am, Paul N <gw7...@aol.com> wrote:

> If I'm within a switch, then saying "case 10:" creates a sort of
> label. Is it possible to jump directly to one of these, eg "goto case
> 12;"? I realise this can be done by adding a "normal" label next to
> the "case" label, and that it might be possible to arrange a similar
> thing by cunning use of fall-through or by changing the variable and
> executing the switch again, but is there a neat syntax to jump to one
> of the other cases?

> Thanks.
> Paul.

A C++ program may be containing more than one switch construct. And
there is a posiblity to find statements such as 'case 1:' in more than
one switch constructs. Hence it if at all this feature was there, it
would have been ambiguous for the compiler.
I don't see a point in considering a `case #n' as a `label'; just
because it terminates with a colon?

In short I would reply your last question with No.


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
paperab  
View profile  
 More options Nov 3, 12:01 pm
Newsgroups: comp.lang.c++
From: paperab <ab9380...@yahoo.co.uk>
Date: Mon, 2 Nov 2009 16:31:28 -0800 (PST)
Local: Tues, Nov 3 2009 12:01 pm
Subject: Re: Goto case?
On Nov 2, 10:33 pm, Paul N <gw7...@aol.com> wrote:

> If I'm within a switch, then saying "case 10:" creates a sort of
> label. Is it possible to jump directly to one of these, eg "goto case
> 12;"? I realise this can be done by adding a "normal" label next to
> the "case" label, and that it might be possible to arrange a similar
> thing by cunning use of fall-through or by changing the variable and
> executing the switch again, but is there a neat syntax to jump to one
> of the other cases?

> Thanks.
> Paul.

A case expression is not a label (and in any case must be a
constant).
So there is no sort of label at all.
Cheers

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bo Persson  
View profile  
 More options Nov 4, 4:10 am
Newsgroups: comp.lang.c++
From: "Bo Persson" <b...@gmb.dk>
Date: Tue, 3 Nov 2009 17:40:38 +0100
Local: Wed, Nov 4 2009 4:10 am
Subject: Re: Goto case?

Paul N wrote:
> If I'm within a switch, then saying "case 10:" creates a sort of
> label. Is it possible to jump directly to one of these, eg "goto
> case 12;"? I realise this can be done by adding a "normal" label
> next to the "case" label, and that it might be possible to arrange
> a similar thing by cunning use of fall-through or by changing the
> variable and executing the switch again, but is there a neat syntax
> to jump to one of the other cases?

> Thanks.
> Paul.

No.

Perhaps the "neat" way is to factor the common code out to a separate
function, and call that one from several locations.

Bo Persson


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Mick  
View profile  
 More options Nov 4, 4:26 am
Newsgroups: comp.lang.c++
From: Mick <mick...@verizon.net>
Date: Tue, 03 Nov 2009 11:56:01 -0500
Local: Wed, Nov 4 2009 4:26 am
Subject: Re: Goto case?

Paul N wrote:
> If I'm within a switch, then saying "case 10:" creates a sort of
> label. Is it possible to jump directly to one of these, eg "goto case
> 12;"? I realise this can be done by adding a "normal" label next to
> the "case" label, and that it might be possible to arrange a similar
> thing by cunning use of fall-through or by changing the variable and
> executing the switch again, but is there a neat syntax to jump to one
> of the other cases?

> Thanks.
> Paul.

Create a function to call from the case and call that function.

--
  ------------
< I'm Karmic >
  ------------
   \
    \
        ___
      {~._.~}
       ( Y )
      ()~*~()
      (_)-(_)


    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Bill Davy  
View profile  
 More options Nov 4, 9:31 pm
Newsgroups: comp.lang.c++
From: "Bill Davy" <B...@SynectixLtd.com>
Date: Wed, 4 Nov 2009 10:01:05 -0000
Local: Wed, Nov 4 2009 9:31 pm
Subject: Re: Goto case?
"Bo Persson" <b...@gmb.dk> wrote in message

news:7lb4o4F2f49mkU1@mid.individual.net...

But there is the lovely code (Tom Duff's (May 7, 1984) method for fast
copying) which should be kept tidied away in a function and with a good
comment somewhere..

    Reply    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google