Usually when someone declares using namespace std;
(I know that it is a bad habit), They should declare it like that:
# include <iostream>
using namespace std;
int main()
{
// Some code here...
return 0;
}
But it is a completely different story here. The using namespace std;
is sometimes located in int main()
(Code 1.12), Maybe in a function named Hello (Code 1.13):
Code 1.12
# include <iostream>
int main()
{
using namespace std;
// Some code after namespace...
return 0;
}
Code 1.13
# include <iostream>
void Hello()
{
using namespace std;
// Some code again...
}
int main() // Adding up main just to ensure there are no errors
{
return 0;
}
Why do they need to initialize using namespace std;
, in a function or in function main
?