In C++, it is possible to omit namespace keyword and use the using directive to avoid having to prefix every standard library function or object with the std:: namespace prefix. Here’s an example:
#include
using namespace std;
int main() {
string name;
cout << "Enter your name:";
getline(cin, name);
cout << "Hello, " <
In this example, we include the iostream header file, and then use the using directive to bring the entire std namespace into the current scope. This means that we can use the string, cout, cin, and getline() functions without having to prefix them with std::.
Note that using the using directive can potentially cause naming conflicts if two different namespaces define objects or functions with the same name. To avoid this, it is generally recommended to use the std:: prefix to explicitly qualify standard library functions and objects.
Learners TV is a website that is designed to educate users and provide instructional material on particular subjects and topics.