C++ general programming help

I was wondering if i can put a switch statement inside an if statement. i tried it and it worked fine but just because it worked doesnt mean there will be issues. so i was wondering if this can be done without any nasty side effects. Also why is goto rarely used by programmers?? it seems like a useful function. But the main reason for this thread is i want to know if there is a site for C++ that teaches you the do's and dont's of programming, basic stuff like that, does this site offer that? what i mean by do's and dont's is like a site that lists all of the things that you shouldnt do when programming and things that can cause problems like nesting if statements for example.
Last edited on
I was wondering if i can put a switch statement inside an if statement.

Sure. You can nest if and switch (and while, for, etc.) as deeply as you think is useful. Although if you end up nesting things too deply, that's your cue that you're trying to do too much in a single function and should split it up into proper subtasks.

Also why is goto rarely used by programmers??

Because it's not necessary and can make it next to impossible to follow the program flow for all possible cases if used incorrectly (like jumping back and forth and only under specific conditions).

There are certainly style guidelines for C++ to be found on the internet, but for the most part you should take them with a grain of salt. Some people will try to sell you the most ridiculous things as "good style". However, "Effective C++" by Scott Meyers is a good read, most of the things he recommends make sense and are good practice.
Last edited on
I see. I downloaded the PDF of the book and i'll definetly read it thanks.
Topic archived. No new replies allowed.