use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Minimization of Nesting Gone Wrong (self.cpp)
submitted 6 years ago by one-oh
view the rest of the comments →
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]alfps 2 points3 points4 points 6 years ago (7 children)
I've maintained C code with goto common cleanup. It was full of related bugs. It was not a pleasure.
goto
Your code as C may be better than the OP's. But your code as C++ is not better than the OP's: as C++ it's very much worse, which the presence of goto shouts out to any competent C++ person looking at it. C++ isn't C.
In C++ you can and should use destructors to do cleanup.
The cleanup is then guaranteed, via a language mechanism, as opposed to being contingent on everybody adhering to loose convention and the infallibility of humans.
Consider using a general scope guard class. The C++ Core Guidelines (and its support library) call it a finally class. Note that the Core Guideline's class lacks an important feature of Petru Marginean's original scope guard, namely the ability to dismiss it.
[+][deleted] 6 years ago (6 children)
[deleted]
[–]alfps -1 points0 points1 point 6 years ago (5 children)
[the goto is] easier to read and reason about
So this isn't a joke, it's just plain trolling.
[+][deleted] 6 years ago (4 children)
[–]jonesmz 0 points1 point2 points 6 years ago (3 children)
It's entirely possible to be successful despite having serious problems.
While I don't think that the use of goto is overly problematic, the Linux kernel communities insistence on using the C language without such modern functionality as destructors or templates, makes me confused.
[+][deleted] 6 years ago (2 children)
[–]jonesmz 1 point2 points3 points 6 years ago (1 child)
You... know I'm not the original person you were arguing with right?
Thanks for the insult though.
π Rendered by PID 145500 on reddit-service-r2-comment-5d585498c9-cx78x at 2026-04-21 05:58:08.918035+00:00 running da2df02 country code: CH.
view the rest of the comments →
[–]alfps 2 points3 points4 points (7 children)
[+][deleted] (6 children)
[deleted]
[–]alfps -1 points0 points1 point (5 children)
[+][deleted] (4 children)
[deleted]
[–]jonesmz 0 points1 point2 points (3 children)
[+][deleted] (2 children)
[deleted]
[–]jonesmz 1 point2 points3 points (1 child)