For teacher which of these will you rely most for teaching students, your experiences or by the books? |
I
am a teacher. And that is a false dichotomy. The answer is, "both."
I criticized your code because you used a function from <algorithm> and a class from <string> without #including either. This is
non-standard code, and it
will fail to compile on
at least one strictly conformant C++ compiler.
That
some IDEs or compilers fix your mistake for you behind the scenes, whether that be on purpose or because one particular implementation of the STL was sloppy with includes, is not a valid rationalization for the "rightness" of explicitly omitting the proper includes. Doing that does not demonstrate any experience, but a lack of experience. (BTW, Code::Blocks is an IDE, and uses the GCC to compile your programs.)
After (kindly) remonstrations, having the chutzpah to make claims about the requirements for compiler implementations of the STL, to post incomplete code as a solution and claim it is for the "student's" good to have to deal with unexplained omissions like that, and to excuse yourself because "there are more than 101 ways to solve a [problem]," is pure nonsense. Teachers have a responsibility to proffer correct code and not saddle their students with incorrect practices. We have enough morons teaching students to use system() and other like cruft already. And, while there are often many ways to solve a problem, sometimes there are, actually, only one or two. In either case, once you choose a solution, it needs to be
correct, else it isn't really a solution, is it?
I hate it when I do something stupid and get flack for it, but
I have learned by experience it is best to simply accept the critisizm and not make the same mistake again. Perhaps you ought to do the same.
[edit] Fixed typo and added an adverb