Coupon Accepted Successfully!


Namespace Alias

Alias means another name. A namespace alias is designed to specify another name to an existing namespace. It is useful if the previous name is long. We can specify a short name as alias and call the namespace members. The following program explains how an alias is specified:


21.20 Write a program to specify alias to existing namespace.


using namespace std;

namespace number


int n;

void show()

{cout<<“\n n=”<<n;}


int main()


namespace num=number;



return 0;







Explanation: In the above program, the namespace number is defined. In the function main(), its alias name is created as follows:

Namespace num=number;

The num is another name given to the namespace number. The member of the namespace number can be accessed using both the names, that is, num and number. The variable n is accessed using the name num, and the function show() is accessed using the name number.

Test Your Skills Now!
Take a Quiz now
Reviewer Name