0

In this two code which one is good practice for doing some project? I'm used to using "using namespace std;" is there any problem to use this? or i use scope resolution operator?

code 1:

#include<iostream>
 using namespace std;
 int main()
 {
  cout<<"Hello world"<<endl;
  return 0;
  }

code 2:

  #include<iostream>
  int main()
  {
   std::cout<<"Hello world"<<std::endl;
   return 0;
   }
 
  • 4
    Does this answer your question? [Why is "using namespace std;" considered bad practice?](https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice) – The Forest And The Trees Oct 19 '20 at 09:04
  • Also, `std::endl` is not good practice, as it flushes the buffer, which is a costly operation. Just use `'/n'` for a new line. And you don't have to `return 0;` from main. – JHBonarius Oct 19 '20 at 10:23

0 Answers0