Click here to Skip to main content
13,830,639 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


2 bookmarked
Posted 31 Mar 2011
Licenced CPOL

The goto-less goto!

, 2 Apr 2011
Rate this:
Please Sign up or sign in to vote.
Here goes my alternate.I am a C++ programmer. My goal is always to try to make code short and simple.bool bFailed=false;if (!bFailed) bFailed= condition1_fails;if (!bFailed) bFailed= condition2_fails;if (!bFailed) bFailed= condition3_fails;if (bFailed) DoFailedCleanup();else {...
Here goes my alternate.
I am a C++ programmer. My goal is always to try to make code short and simple.

bool bFailed=false;
if (!bFailed) bFailed= condition1_fails;
if (!bFailed) bFailed= condition2_fails;
if (!bFailed) bFailed= condition3_fails;

if (bFailed) DoFailedCleanup();
else { 


  • Short and simple to read
  • You can set debug breakpoints in any condition to test return values
  • No functions / exceptions needed


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Jose David Pujo
Software Developer (Senior) Freelancer
Spain Spain
No Biography provided

You may also be interested in...

Comments and Discussions

GeneralFirst It Does Work and Two I Think your missing Your If Stat... Pin
charles henington7-Apr-11 19:22
membercharles henington7-Apr-11 19:22 
Generalhow about this bool bFailed = false; if (!bFailed) bFailed ... Pin
charles henington6-Apr-11 15:32
membercharles henington6-Apr-11 15:32 
GeneralRe: Good approach, but I think that it doesn't work: bFailed = ... Pin
Jose David Pujo6-Apr-11 22:12
memberJose David Pujo6-Apr-11 22:12 
GeneralReason for my vote of 4 For simple code, this would work wel... Pin
EFEaglehouse5-Apr-11 5:00
memberEFEaglehouse5-Apr-11 5:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web02 | 2.8.190114.1 | Last Updated 2 Apr 2011
Article Copyright 2011 by Jose David Pujo
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid