sentinel processing, C++ no break label

W

werwer

How do C++ programmers build sentinel, what I'd call an
"error frame" (in this case), stuctures? It's a great
way to parse, error process, and avoid 'if' depth. Since
C++ doesn't have a break/continue LABEL I can't see
anyother way than to use a goto. This is no big deal in
Java or Perl, but C++ guys seem adverse to idea. How would
you do something like this?


status = FAIL;
ERROR_FRAME: for(;;) {

for(...;...;...) {
if(..) {
goto LEAVE_PROGRAM;
}
}

if (bad) {
goto LEAVE_PROGRAM;
}

status = OK;
goto LEAVE_PROGRAM;
}

LEAVE_PROGRAM: return status
 
L

Larry I Smith

werwer said:
How do C++ programmers build sentinel, what I'd call an
"error frame" (in this case), stuctures? It's a great
way to parse, error process, and avoid 'if' depth. Since
C++ doesn't have a break/continue LABEL I can't see
anyother way than to use a goto. This is no big deal in
Java or Perl, but C++ guys seem adverse to idea. How would
you do something like this?


status = FAIL;
ERROR_FRAME: for(;;) {

for(...;...;...) {
if(..) {
goto LEAVE_PROGRAM;
}
}

if (bad) {
goto LEAVE_PROGRAM;
}

status = OK;
goto LEAVE_PROGRAM;
}

LEAVE_PROGRAM: return status

read up on try/throw/catch

Larry
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top