Hello friends, Welcome to your Techgsr.co blog. And today in this article we will learn about how to use namespaces be nested in C++?Write the program. So let’s go to our topic
#include <iostream> int x = 20; namespace outer { int x = 10; namespace inner { int z = x; // this x refers to outer::x } } int main() { std::cout<<outer::inner::z; //prints 10 getchar(); return 0; }
Output :
10.
Related Post:-
So I hope that you learn about the this program And if you have any more queries about progrmming ,web Devlopment ,tech,computer relegated then feel free to discuss your problem in the comment section.Thank you so much and come back for more updates about Techgsr.co