I have a bunch of code like this:
#include <iostream> using namespace std; void swap(int *a, int *b) { int temp = *a; *a = *b; *b = temp; } int main() { int a = 7; int b = 5; swap(a, b); cout << a << b; // prints 57 as expected }
However, if I remove using namespace std
, the compiler raises an error about int
to int*
conversion. Why does the code work with using namespace std
even though I didn't use the method with the &
operator?
using namespace std;
considered a bad practice in C++?