The journey of 100 days of code began with learning the fundamentals of c++. I got myself registered with the Fork CPP course on ‘geeks for geeks’.
Since this was day 1, I didn’t expect myself to complete the entire theory course on day 1 but still, I read 3 out of 16 theory parts. Those were: ‘writing first c++ program’, ‘C++ data types’ and ‘basic input/output in c++’.
These lectures weren't something new since I already am aware of these fundamentals. Still, I realized I forgot about some very basic concepts like the data types and their memory sizes, and what is ‘#inculde’. Something I learned new was that ‘Why “using namespace std” is considered a bad practice’. If I were to answer this:
“using namespace std” is considered bad practice since it includes the entire std into the current namespace of the program. Instead, using ‘std::’ whenever we intend to declare a type is a good practice. There will be instances when we shall be supposed to something called the ‘foo. h’ library. It contains the same ‘cout<<’ operator that the ‘iostream’ library does. Thus it can create ambiguity for the compiler to identify to which library does the ‘cout<<’ points.
Thus we use ‘std::cout’ and ‘foo::cout’ separately to specify which library we intend to point to. And I know it is tedious to write std:: in almost every single line of our code. So for that, we can use typedefs.
Conclusion: Keep on using “using namespace std” until you don’t need to work with libraries having different purposes.
You can read more about this topic here.
I will see you in the next blog. (Most likely tomorrow).