C++ program to illustrate the use of same variable within Namespace and main() function

//use of same variable num within namespace and main() function
//use it in main() program

#include <iostream>
using namespace std;
namespace Variables
{
    int num=23;
}
int main()
{
    int num=45;
    cout<<endl<<"Value of num="<<num;
   
cout<<endl<<"To use value of num within namespace";
    cout<<endl<<"Value of num="<<Variables::num;
    return 0;
}

No comments:

Post a Comment