Loading...
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
Namespaces are used to group entities like classes, objects, and functions under a name. They prevent naming collisions between different libraries.
All standard C++ features (cout, cin, vector, etc.) are inside the std namespace.
std::cout << "Hello"; // Full name using namespace std; // Shortcut (Caution!) cout << "Hello";
namespace MyLib {
void log(string s) { ... }
}
MyLib::log("Test");Avoid using namespace std; in header files or large projects. It can lead to "Namespace Pollution" where names from different libraries clash.