Article View: comp.std.c++
Article #283Re: case()
From: Henry Spencer
Date: Wed, 08 Aug 1990 15:38
Date: Wed, 08 Aug 1990 15:38
26 lines
1122 bytes
1122 bytes
In article <26842@pasteur.Berkeley.EDU> krste@ICSI.Berkeley.EDU ( Krste Asanovic) writes:
>The C/C++ switch statement is very limited as it only allows integer
>expressions. I'd like to suggest a more general case statement.
>The syntax would be,
>
> case (exp) {
> case val1 : s1;
> case val2 : s2;
> default : sOther;
> }
Try this, which is already legal C++:
if (exp == val1)
s1;
else if (exp == val2)
s2;
else
sOther;
It is a bit less convenient to type, but does the job. I greatly doubt
that X3J16 will sanction a new and untried feature which duplicates
an existing one with only a trivial variation in syntax.
--
The 486 is to a modern CPU as a Jules | Henry Spencer at U of Toronto Zoology
Verne reprint is to a modern SF novel. | henry@zoo.toronto.edu utzoo!henry
Technical Details
Message-ID:
<1990Aug8.153832.2629@zoo.toronto.edu>Path:
arc1-ca.pugleaf.net!utzoo!henryReferences:
<26842@pasteur.Berkeley.EDU>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++ Path: arc1-ca.pugleaf.net!utzoo!henry From: henry@zoo.toronto.edu (Henry Spencer) Subject: Re: case() Message-ID: <1990Aug8.153832.2629@zoo.toronto.edu> Organization: U of Toronto Zoology References: <26842@pasteur.Berkeley.EDU> Date: Wed, 8 Aug 90 15:38:32 GMT