CSC112 Spring 2016 Examples
1#include <iostream> 2 3//define a namespace called ns1 4namespace ns1 5{ 6 void f() { 7 std::cout << "ns1 function f" << std::endl; 8 } 9} 10 11 12//define a namespace called ns2 13namespace ns2 14{ 15 void f() { 16 std::cout << "ns2 function f" << std::endl; 17 } 18} 19 20 21int main() 22{ 23 //call our functions within the two namespaces 24 ns1::f(); 25 ns2::f(); 26 27 return 0; 28} 29