//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;
}
//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