How to use using namespace std inside a function in C++

1 Answer

0 votes
#include <iostream>

void example() {
    using namespace std;
    
    string str = "C++ Programming";
    
    cout << str << "\n";
}

int main() {
    
    example();
    
    int x = 10;

    std::cout << x;
}




/*
run:

C++ Programming
10

*/

 



answered Dec 7, 2023 by avibootz
...