1
00:00:02,040 --> 00:00:10,440
I'm no offense to my general myself, but when we write big program, so in that program we write,

2
00:00:10,560 --> 00:00:16,710
we use multiple variables, we use many functions and also we define many classes.

3
00:00:17,370 --> 00:00:22,620
If we are defining when we are using multiple classes, functions are variables.

4
00:00:22,620 --> 00:00:28,140
So there are chances that they will be complex in between the names of variables, and because of that

5
00:00:28,140 --> 00:00:29,280
we may get errors.

6
00:00:29,520 --> 00:00:32,700
So how to avoid such kind of naming complex.

7
00:00:33,600 --> 00:00:39,750
So for that in various programming languages, various techniques are provided, for example, in C++

8
00:00:39,750 --> 00:00:40,320
language.

9
00:00:40,980 --> 00:00:43,170
But we will see some examples.

10
00:00:47,610 --> 00:00:54,300
So see, here in this code we have defined this value variable.

11
00:00:55,170 --> 00:00:57,450
So here also we are defined here.

12
00:00:57,460 --> 00:00:59,520
Also we are defined here also defined.

13
00:00:59,700 --> 00:01:05,190
So whenever there is a global variable and local variable, so preference is always one to local variable.

14
00:01:06,330 --> 00:01:10,110
Now this is a valid variable and we all look at it 200.

15
00:01:10,680 --> 00:01:16,580
And this value variable, we are allocated 300, but at the same name is used there.

16
00:01:16,590 --> 00:01:20,990
So definitely when we run that it will take value for this well.

17
00:01:21,000 --> 00:01:25,650
But I want to differentiate this well and this will go to differentiate it.

18
00:01:25,680 --> 00:01:30,030
I have mentioned I have defined this value variable in this namespace.

19
00:01:31,800 --> 00:01:40,800
So whenever so see here we'll run this program so normally when we write this and when we compile this

20
00:01:40,800 --> 00:01:41,520
program.

21
00:01:50,780 --> 00:01:54,110
So here you can see here we got output 200.

22
00:01:55,010 --> 00:01:58,240
Now see, but I don't want this variable.

23
00:01:58,250 --> 00:02:03,740
I want to access this very variable so I can take help of this namespace, as I mentioned here.

24
00:02:03,800 --> 00:02:10,280
So I can write here and I can use this resolution operator.

25
00:02:11,980 --> 00:02:13,740
So I will compile this.

26
00:02:15,130 --> 00:02:18,400
And so this time I got 300.

27
00:02:19,630 --> 00:02:22,660
So here we have use namespace for the variable.

28
00:02:22,720 --> 00:02:26,180
In the same way we can use namespace for the function.

29
00:02:26,560 --> 00:02:30,640
So here you can see here we have defined function value.

30
00:02:31,360 --> 00:02:33,700
And again, we are defining the function.

31
00:02:33,700 --> 00:02:40,870
But working of this two value function are different, but names are same so I can differentiate them

32
00:02:40,870 --> 00:02:42,520
by using namespace.

33
00:02:42,550 --> 00:02:49,690
So I have defined this value function in one namespace and this value function in another namespace

34
00:02:49,690 --> 00:02:53,570
and how it is accessed by the name of the namespace.

35
00:02:53,590 --> 00:02:56,710
So see, this is in this one and this value function.

36
00:02:56,950 --> 00:02:59,200
This is true and this value function.

37
00:02:59,410 --> 00:03:05,180
And also here we are using this variable X by using this namespace name in.

38
00:03:07,000 --> 00:03:09,370
So we'll see output of this program.

39
00:03:16,040 --> 00:03:18,140
So here you can see this.

40
00:03:18,980 --> 00:03:24,680
So here we are getting a five year, 200 and extended 100.

41
00:03:28,480 --> 00:03:31,100
We can also use namespace for the cloud.

42
00:03:31,120 --> 00:03:35,800
So here you can see in this program two classes are defined.

43
00:03:36,280 --> 00:03:39,430
This is one sample class and this is another sample class.

44
00:03:39,520 --> 00:03:40,840
Both are the same name.

45
00:03:41,300 --> 00:03:44,840
So to differentiate it, we have this different namespace.

46
00:03:44,860 --> 00:03:51,370
So we mentioned this sample class in this namespace and this in this namespace.

47
00:03:51,370 --> 00:03:58,590
In this one we mentioned we are defined another class sample while using while creating variable our

48
00:03:58,600 --> 00:04:02,950
object of these classes we have to use name of the namespace.

49
00:04:05,410 --> 00:04:09,980
So see, here, we run this program.

50
00:04:14,780 --> 00:04:17,420
We have compiled this and now we will.

51
00:04:18,140 --> 00:04:22,810
So this is for a sample class of this first sample class.

52
00:04:22,850 --> 00:04:26,090
Here you can see this method of first sample class.

53
00:04:27,170 --> 00:04:34,670
And this is from the sample class of another sample that we are defined in namespace instance.

54
00:04:34,820 --> 00:04:40,700
So in namespace we can have variables, we can have functions and we can help classes also.

55
00:04:41,120 --> 00:04:49,640
So to differentiate among different classes, variables and functions, we can use this namespace.

56
00:04:51,830 --> 00:04:55,460
So that is how namespace is used in C++ language.

