Introducing Namespaces in c++
This video tutorial explains about the namespaces in c++ programming.
You are gonna learn what is a namespace, why we have to use a namespace, how to declare a namespace, how to access the members defined in a namespace in detail with example.
source code for this tutorial
code for " file_one.cpp "
namespace one{ int x = 10; void display(){ cout << "display from file one"<<endl; } }code for " file_two.cpp "
namespace Two{ int x = 20; void display(){ cout << "display from file two"<<endl; } }
code for "main.cpp"
#include <iostream> using namespace std; #include "file_one.cpp" #include "file_two.cpp" int main() { using namespace one; //using namespace Two; display(); return 0; }