1
00:00:01,720 --> 00:00:02,380
Hi everyone.

2
00:00:02,380 --> 00:00:06,210
So in this video we are going to learn about civilization.

3
00:00:06,460 --> 00:00:12,850
So what is civilization to civilization is a process of storing and driving the state of an object.

4
00:00:12,890 --> 00:00:16,270
I know the definition is very weird and it is tough to understand.

5
00:00:16,270 --> 00:00:19,540
But first let us write the code and then we will understand with the help of code.

6
00:00:20,230 --> 00:00:22,320
So this is my final situation not CBB.

7
00:00:22,320 --> 00:00:25,750
Now what I'm going to do so obviously I have to include the File f stream

8
00:00:29,180 --> 00:00:31,810
so first let us create a class.

9
00:00:32,000 --> 00:00:37,620
Suppose I want to create a class a student and what I want private properties.

10
00:00:37,700 --> 00:00:42,920
So let's say I want to take three private properties so first is what is the name of the student.

11
00:00:43,340 --> 00:00:45,980
Second is what is the rule number of the student.

12
00:00:45,980 --> 00:00:51,300
And third is basically what is the branch of the student.

13
00:00:51,360 --> 00:00:53,210
And now let us create a constructor

14
00:00:57,340 --> 00:01:00,720
so the student what it will take it will take.

15
00:01:00,720 --> 00:01:02,410
What is the name of the student.

16
00:01:02,410 --> 00:01:07,300
It will take the total number of the student and it will take the branch of the student.

17
00:01:07,360 --> 00:01:08,680
So this is string branch.

18
00:01:08,740 --> 00:01:11,950
Saudi now after doing this.

19
00:01:11,960 --> 00:01:15,050
Let us do so what is my name.

20
00:01:15,050 --> 00:01:21,770
Name is an it is and actually what is the rule number.

21
00:01:22,680 --> 00:01:29,800
So it is odd and the branches be.

22
00:01:29,810 --> 00:01:34,870
So what I want to do so it does create an object first.

23
00:01:34,880 --> 00:01:45,230
So student as one so let's say the name is Doc so rule number is let's say today and the branches let's

24
00:01:45,230 --> 00:01:48,890
say CAC simple.

25
00:01:48,890 --> 00:01:50,960
Now I want to store this object.

26
00:01:50,960 --> 00:01:53,990
So basically I want to store the data in a fine.

27
00:01:54,020 --> 00:01:58,010
So basically I have to use output stream.

28
00:01:58,070 --> 00:02:00,170
Let's say the name of the object is all office.

29
00:02:00,170 --> 00:02:02,340
I want to create a file.

30
00:02:02,490 --> 00:02:11,050
Student dot the 60 and let's say I want to get whatever is present in that fight.

31
00:02:11,090 --> 00:02:15,300
So if you will see basically this is our file folder.

32
00:02:15,350 --> 00:02:16,520
So this is.

33
00:02:16,520 --> 00:02:22,430
So this is and predictably so there is no need to truncate because it will create a new file student

34
00:02:22,500 --> 00:02:24,520
or the extra file will be created.

35
00:02:24,570 --> 00:02:30,300
Now if I want to stored this object store object S1 would I have to do so I have to do something like

36
00:02:30,300 --> 00:02:35,180
this or office s or not name stored.

37
00:02:35,180 --> 00:02:41,120
Name then you have to do something like this or if this is to dot.

38
00:02:41,290 --> 00:02:41,950
So it is.

39
00:02:41,950 --> 00:02:42,490
Rule number.

40
00:02:42,490 --> 00:02:54,160
So this is really no and then you will do well if S S T sorry this is S1 actually S1 and then you will

41
00:02:54,160 --> 00:02:57,830
do all of this S1 and art branch

42
00:03:01,660 --> 00:03:09,430
and finally you will do or if it's not close if I want to store the data in a store not the extra fine

43
00:03:09,880 --> 00:03:15,480
I have to do this but this is very cumbersome process I have to write many lines of code.

44
00:03:15,490 --> 00:03:20,080
So what I want to do so I want that if I will write or if s

45
00:03:22,900 --> 00:03:26,670
s1 so I want to do something like this.

46
00:03:26,710 --> 00:03:27,770
So this line should work.

47
00:03:27,820 --> 00:03:29,730
It should write name.

48
00:03:29,980 --> 00:03:36,850
It should write or number and this line should write the branch inside the file to then dot the 60.

49
00:03:36,850 --> 00:03:40,240
So I want this line to work and it is very obvious.

50
00:03:40,300 --> 00:03:47,710
So for this line to look what we have to do we have to overload this operator we have to overload this

51
00:03:47,710 --> 00:03:55,480
operators on this overload this operator so for overloading the operator what I have to do.

52
00:03:55,480 --> 00:04:00,730
So first of all what is the operator get when we want to overload.

53
00:04:00,780 --> 00:04:05,560
So we want to overload this operator so.

54
00:04:05,620 --> 00:04:08,140
This one I want to overload this operator.

55
00:04:09,550 --> 00:04:18,170
So what it will take it will take an object off f stream glass output file stream glass biodefense let's

56
00:04:18,490 --> 00:04:22,960
say the name is or this it will also take a Student object

57
00:04:27,720 --> 00:04:31,290
biodefense Student object biodefense.

58
00:04:31,290 --> 00:04:33,490
Let's say the name is s.

59
00:04:33,750 --> 00:04:36,580
So you have to write friend in front of it friend.

60
00:04:36,630 --> 00:04:37,980
And what do you write it.

61
00:04:38,050 --> 00:04:43,760
What I will write and so I will have done an object of output file a stream class.

62
00:04:43,770 --> 00:04:48,410
So I want to return an object of our proposed stream class biodefense.

63
00:04:48,540 --> 00:04:53,250
So I want to write an object of this class biodefense so this is written by reference and I am taking

64
00:04:53,250 --> 00:04:57,530
input biodefense so what I have to do.

65
00:04:58,680 --> 00:05:09,090
So basically what I will do I will do all this work inside this function.

66
00:05:09,140 --> 00:05:10,640
So basically I am storing the name.

67
00:05:10,640 --> 00:05:17,180
So here the object the other name of the student is s so I will make it s I am storing the name I am

68
00:05:17,180 --> 00:05:19,340
storing the whole number and I am studying the branch.

69
00:05:19,400 --> 00:05:26,740
And finally I have to return the object biodefense so I will return with this.

70
00:05:26,780 --> 00:05:29,460
So this is all that we have to do now if you will write here.

71
00:05:30,560 --> 00:05:36,290
So if I will write or if this is one to the name of the student is S one.

72
00:05:36,290 --> 00:05:40,220
So if you write or if it's S1 So what will happen.

73
00:05:40,220 --> 00:05:45,510
This piece of code will get executed and our name rule number and branch will get stored.

74
00:05:45,590 --> 00:05:47,080
So this is how it will look.

75
00:05:47,090 --> 00:05:48,440
So let us start program

76
00:05:54,080 --> 00:05:55,300
so we are not printing anything.

77
00:05:55,300 --> 00:05:57,460
That's why our screen is empty.

78
00:05:57,590 --> 00:05:58,880
Now let's see this four letter again.

79
00:05:59,330 --> 00:06:04,540
So I have this student file that does open this flight landed here we have a block party and CSC.

80
00:06:05,510 --> 00:06:07,720
So this is very important concept.

81
00:06:07,730 --> 00:06:11,070
What we are doing so just writing.

82
00:06:11,120 --> 00:06:16,460
We just overloaded this operated and we can do this.

83
00:06:16,550 --> 00:06:20,160
So all this work is basically done inside the class.

84
00:06:20,870 --> 00:06:28,670
And now what I mean is looking very very simple subdomain becomes very simple you can see.

85
00:06:28,750 --> 00:06:32,250
So this is our I mean we are just creating an object.

86
00:06:32,470 --> 00:06:36,790
Then I want to open this file this render the extra file then I am able to do this.

87
00:06:36,790 --> 00:06:38,530
So this is very powerful.

88
00:06:38,560 --> 00:06:41,340
Now similarly I want to read the file.

89
00:06:41,530 --> 00:06:43,970
So for reading the file what I want to do.

90
00:06:43,990 --> 00:06:49,650
So I want to do something like this IFRS S1 again.

91
00:06:49,650 --> 00:06:51,980
So if you want to do this what do we have to do.

92
00:06:52,050 --> 00:06:53,710
So you will overload this operator.

93
00:06:54,840 --> 00:06:58,390
So just like we overloaded this operator we will overload this operator also.

94
00:06:59,070 --> 00:07:02,960
So let us write the code.

95
00:07:03,420 --> 00:07:10,490
So what I want to do I want to create a student let's say S2 then I want to do something like this.

96
00:07:10,500 --> 00:07:13,250
So basically I have to create an object first.

97
00:07:13,380 --> 00:07:21,940
So input file stream let's say the name of the object is a office and I want to read this file student

98
00:07:22,380 --> 00:07:28,150
not the 60 I want to read its content then I want to do something like this.

99
00:07:28,170 --> 00:07:35,350
I f s student as to okay.

100
00:07:35,360 --> 00:07:36,650
So I want to do like this.

101
00:07:36,710 --> 00:07:41,340
I first wrote it s true and then basically what I will do I will print the content where this present

102
00:07:41,380 --> 00:07:42,540
inside is true.

103
00:07:42,590 --> 00:07:46,960
So basically I will do something like this as to dart name

104
00:07:55,850 --> 00:08:01,250
then I will print you limit so Astronaut William

105
00:08:05,220 --> 00:08:07,380
and then what I want to do.

106
00:08:07,380 --> 00:08:11,080
So I also want to print what is the branch

107
00:08:16,700 --> 00:08:23,500
so astronaut bench Okay so I want to do something like this.

108
00:08:23,510 --> 00:08:25,410
ISIS is too.

109
00:08:25,520 --> 00:08:26,540
So again what do we do.

110
00:08:26,540 --> 00:08:28,400
We will overload this operator.

111
00:08:29,030 --> 00:08:30,770
So let's just copy this called

112
00:08:36,740 --> 00:08:40,690
so this time I want to return an object of input file stream biodefense.

113
00:08:41,060 --> 00:08:44,330
I want to overload this operator.

114
00:08:44,330 --> 00:08:47,060
So this is in file stream object.

115
00:08:47,060 --> 00:08:54,140
The name is Isis and I have to pass distributed by defense so that the changes will get reflected here.

116
00:08:54,150 --> 00:08:58,200
Now what I have to do so instead of office I will write a office.

117
00:08:58,230 --> 00:08:59,610
Similarly I office here.

118
00:09:00,180 --> 00:09:01,400
Similarly AFSC

119
00:09:12,670 --> 00:09:13,390
and similarly

120
00:09:20,550 --> 00:09:26,000
so obviously we have to change the operator also take input

121
00:09:28,690 --> 00:09:31,850
and finally what I will do so I will return ISIS.

122
00:09:31,870 --> 00:09:35,530
So this is exactly the same code just like this one.

123
00:09:35,950 --> 00:09:37,680
Here we are writing the data to the file.

124
00:09:37,700 --> 00:09:40,620
And here we are reading the data from the file.

125
00:09:40,630 --> 00:09:42,790
So finally I am returning ISIS.

126
00:09:42,880 --> 00:09:43,900
So here what I am doing.

127
00:09:43,900 --> 00:09:49,030
So this the data that we are reading that will stored that will be stored in this trial and I am printing

128
00:09:49,030 --> 00:09:52,020
the name and printing the rule number and I am printing the branch.

129
00:09:52,870 --> 00:09:57,340
Okay so let us run our program so first of all what will happen.

130
00:09:57,340 --> 00:10:04,420
So this file is already containing this data but we do not need to worry because if you will in this

131
00:10:04,420 --> 00:10:05,350
program what will happen.

132
00:10:05,350 --> 00:10:06,770
So this is with us.

133
00:10:06,790 --> 00:10:10,930
So by default it is by default it is truncate.

134
00:10:10,990 --> 00:10:11,730
So what will happen.

135
00:10:11,740 --> 00:10:17,940
It will delete the old content and it will again stored these values.

136
00:10:17,950 --> 00:10:21,100
So if we do not have to worry and then we are creating this object.

137
00:10:21,190 --> 00:10:25,680
So it will contain all these values and we are printing all these values.

138
00:10:25,900 --> 00:10:26,870
And one more thing.

139
00:10:26,890 --> 00:10:29,630
So after doing the work I have to also close the file.

140
00:10:29,800 --> 00:10:32,510
So I if it's not close.

141
00:10:33,220 --> 00:10:36,370
So let us write our program okay.

142
00:10:36,390 --> 00:10:42,100
So we are getting at this line because you can see so we have written the betterment based construct

143
00:10:42,120 --> 00:10:44,790
benzo a default constructor does not exist.

144
00:10:44,860 --> 00:10:54,100
So that's why we have to create a default constructor so this is a default constructor so it will not

145
00:10:54,100 --> 00:11:03,500
contain anything it is empty just empty so in order to run our program so we are getting error because

146
00:11:03,600 --> 00:11:07,390
he had the name rule number and Valentine actually private.

147
00:11:07,390 --> 00:11:10,760
So we have to make them public if we want to access all these things here.

148
00:11:11,250 --> 00:11:18,590
So when it does make them public so now I think everything should work fine.

149
00:11:18,590 --> 00:11:28,050
So let us turn our program and let's see so you can see the name is Brock the all lambast 30 and the

150
00:11:28,050 --> 00:11:31,410
branches CSC and if you will see the file.

151
00:11:31,640 --> 00:11:35,090
So the file is again containing the same content.

152
00:11:35,150 --> 00:11:37,910
What will happen to first discontent will be deleted.

153
00:11:37,910 --> 00:11:39,680
And again I am writing discontent.

154
00:11:40,370 --> 00:11:43,400
OK so that's how everything is working

155
00:11:47,170 --> 00:11:53,890
so you can see with the help of civilization the code that should belong to the class as belonging to

156
00:11:53,890 --> 00:11:54,540
class now.

157
00:11:55,510 --> 00:12:01,930
So now you can see what I mean has become so much simpler and we are just doing a little book inside

158
00:12:01,930 --> 00:12:09,160
our main function and we are able to achieve this with the help of overloading these two operators.

159
00:12:09,250 --> 00:12:12,910
This an operator and this operator.

160
00:12:13,050 --> 00:12:14,210
So this is the computer code.

161
00:12:14,220 --> 00:12:16,050
If you have any doubt and civilization.

162
00:12:16,080 --> 00:12:17,350
You can definitely ask me.

163
00:12:17,400 --> 00:12:18,670
I will see you in the next one.

164
00:12:18,680 --> 00:12:19,050
Bye bye.
