semsemdiver wrote: |
---|
how do you know this information? |
Time and experience. Make mistakes, learn from them. Ask others, as you did here. Read the source materials on C++ as well as good books written by experts along with online tutorials.
Regarding book
s.... multiple:
https://isocpp.org/wiki/faq/how-to-learn-cpp#buy-several-books
Online tutorials:
There a tutorial here at CPlusPlus, though it is a bit outdated (very little C++14, no C++17/20):
http://www.cplusplus.com/doc/tutorial/
Another good tutorial that is kept up-to-date:
https://www.learncpp.com/
A technical reference of C++, though it can be a bit 'dense' for a beginner:
https://en.cppreference.com/w/cpp
Most printed books tend to be outdated, even recent ones. Online resources can be easier to keep up-to-date.
C++ is continuing to evolve. C++11 changed the language at a fundamental level from what it was before. C++14/17 augmented, added and removed some features. C++20 is close to being officially released, adding more fundamental changes. What works with an earlier standard is not guaranteed to work with later standards. Or has been considerably improved. Random number generation with C++11, for instance.
Above all else, keep writing code. Push the boundaries of what you know.
Become a 'sponge.' Expect to fail and make mistakes.
On a side note, nice to see you didn't fall into the
potential using namespace std;
trap. It defeats the purpose of having namespaces.
https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice