Toggle navigation
How to implement namespace in C++
Rate this article
0 out of 5
In this tutorial we will show you how to implement namespace in C++. After viewing the video tutorial, download the source code and try to modify the code so as to get a feel of what is learned in this video tutorial.
Program
#include<iostream.h>
#include<stdlib.h>
#include<conio.h>
namespace Classes
{
class Sample
{
private:
int I_length,I_breadth;
public:
Sample(int I_dummy1,int I_dummy2)
{
I_length=I_dummy1;
I_breadth=I_dummy2;
}
void Display()
{
int I_area;
I_area=I_length*I_breadth;
cout<<" Area of Rectangle="<<I_area<<" cmsq. ";
}
};
};
int main()
{
cout<<" Calling using scope resolution operator...";
Classes::Sample obj1(8,3);
obj1.Display();
cout<<" Calling using 'using' directive...";
using namespace Classes;
Sample obj2(5,9);
obj2.Display();
getch();
return 0;
}
Source Code
Download
Author :
TekTips Videos
Joined Date :04-Feb-2013
Articles
Posted
27
Messages
Posted
0
Click Here to See Full Profile
Messages
Posted:
Post Your Comments
Name
(Max 50 Chars)
Comments
Paragraph
Normal
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Formatted
Address
Size
1
2
3
4
5
6
Color
Black
Gray
DarkGray
LightGray
White
Aquamarine
Blue
Navy
Purple
DeepPink
Violet
Pink
DarkGreen
Green
YellowGreen
Yellow
Orange
Red
Brown
BurlyWood
Beige
Design
HTML