Topic: Suggestion to enhance "break
Author: Pete Becker <petebecker@acm.org>
Date: Tue, 23 Oct 2001 15:51:12 GMT Raw View
Tinct wrote:
>
> "Break" Jumps out of outer loop/switch scope:
>
> label_outer: for(i=1;i++;i<10) {
> lable_inner: for(j=1;j++;j<10) {
> ...
> break label_outer;
> }
> }
> ... //"break label_outer" jumps here
>
Java does this. It's very hard to read. If you can't write this as a
separate function with a return, goto is a better solution.
--
Pete Becker
Dinkumware, Ltd. (http://www.dinkumware.com)
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
Author: tinct@163.com (Tinct)
Date: Tue, 23 Oct 2001 02:54:01 GMT Raw View
"Break" Jumps out of outer loop/switch scope:
label_outer: for(i=1;i++;i<10) {
lable_inner: for(j=1;j++;j<10) {
...
break label_outer;
}
}
... //"break label_outer" jumps here
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]
Author: Helmut Zeisel <helmut.zeisel@vai.at>
Date: Tue, 23 Oct 2001 09:12:14 GMT Raw View
Tinct wrote:
> "Break" Jumps out of outer loop/switch scope:
>
> label_outer: for(i=1;i++;i<10) {
> lable_inner: for(j=1;j++;j<10) {
> ...
> break label_outer;
> }
> }
> ... //"break label_outer" jumps here
C-Solution: use "goto"
C++ Solution: move the outer loop into a member function
and write "return" instead of "break"
Helmut
---
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@ncar.ucar.edu ]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.research.att.com/~austern/csc/faq.html ]