1) If you have multiple definitions of a function within scope of a prototype or call, the compiler will (or should) error out and tell you what is wrong and where. I mentioned this since you said the program would crash, which means that it would run at all which isn't true since it will not compile.
2) I can picture the provided bad code from your instructor being a typo or something similar to.
|
Hi computerquip and thank you for your help. I definitely need all the help I can get. In my opinion learning is half the fun and the other half is trying to make sense of what I just learned lol.
In regards to #1: Excellent point. I guess if a program was to 'crash' it would do more with stuff like not validating user input such as requiring integers but the user can input characters.
For #2: I suspect(ed) the same thing and that's why I wanted to talk to him before doing anything because I didn't want to cause problems, I even would've been happy if he responded by saying it was a test to see if I would catch it, however, when shown the error and instead of taking some responsibilty he tries to pass the buck of blame. I have to admit, that didn't sit well with me lol. I love learning C++, I love how you all have been extremely patient and helpful with me and I love this site, so I'm going to keep coming back here to supplement my learning, but I just hope I can find an instructor I can actually trust to be actually teaching me proper code. Because now, I'm going to have to double check all of what he's teaching me and that's not cool.
Ok, I believe I got a grasp on this and that was an excellent example. How do you know what code structure to use? Not just code related to namespaces but code in general. I'm finding that C++ allows you, basically, a million different ways to achieve the same result so how do you know what is proper and what isn't? Reading numerous posts on this site, I'm constantly seeing things such (And please don't ask for actual threads because right now, I can't remember lol) as "don't do that, it's not proper", or "why did you write it that way, when you could've just..." etc etc.? Isn't the way something is coded pretty much programmer preference?
For Example:
Being a Chef, I know that you can take a few ingredients and make a basic pancake properly, but there's still a million different ways to make that same pancake using different ingredients, cooking techniques, personal preferences / tastes etc. And depending on the breakfast 'type', which ingredients to use and not to use, which are proper and which are not etc. I hope this is making sense but it's the best analogy I can come up.
Again, thanks to all of you! You've all been a
huge help!