Demonstrates the use of using-declarations and using-directives. : Using « Language « C++






Demonstrates the use of using-declarations and using-directives.

Demonstrates the use of using-declarations and using-directives.
#include <iostream>      
void message()           
{
   std::cout << "Within function ::message()\n";
}
namespace A
{
   using namespace std; 
   void message()       
   {
     cout << "Within function A::message()\n";
   }
}
namespace B
{
   using std::cout;     
   void message(void);  
}
void B::message(void)   
{
   cout << "Within function B::message()\n";
}
int main()
{
   using namespace std;  
   using B::message;     
   cout << "Testing namespaces!\n";
   cout << "\nCall of A::message()" << endl;
   A::message();
   cout << "\nCall of B::message()" << endl;
   message();           
   cout << "\nCall of::message()" << endl;
   ::message();         
   return 0;
} 

           
       








Related examples in the same category