Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,180 --> 00:00:04,019
We need to take a break from applying the big three steps and fix the copy constructor.
2
00:00:07,650 --> 00:00:12,690
So far, we fixed the constructor and we added a geter, the next step should be data center, but there's
3
00:00:12,690 --> 00:00:14,520
something missing in the copy constructor.
4
00:00:14,910 --> 00:00:16,590
So in this lesson, we're going to fix it.
5
00:00:18,840 --> 00:00:21,420
The copy constructor is missing a field update.
6
00:00:23,930 --> 00:00:29,520
We certainly stand to equal to a new object and passed in Nissan as an argument jarvis's the argument
7
00:00:29,540 --> 00:00:31,250
and Nossiter on the copy constructor.
8
00:00:32,400 --> 00:00:38,700
The parameter source story is a reference that points to the Nissan object, this refers to the current
9
00:00:38,700 --> 00:00:43,770
object, the one that's calling the constructor and the copy constructor copies every field from the
10
00:00:43,770 --> 00:00:46,080
source object into the current object.
11
00:00:49,880 --> 00:00:54,830
But wait, it doesn't copy the parts away from the source so that field stays null.
12
00:00:57,720 --> 00:01:02,700
All right, using a raised copy of we're going to set the parts field of the current object being created.
13
00:01:05,560 --> 00:01:07,150
Equal to a copy of the.
14
00:01:08,540 --> 00:01:10,460
Parts away from the source object.
15
00:01:18,240 --> 00:01:20,460
And we're going to copy the full length of the array.
16
00:01:27,140 --> 00:01:30,410
And they're now everything should work, you run your code and test it.
17
00:01:43,810 --> 00:01:48,190
And it works as expected, Nissan 2s parts field, is it not anymore?
18
00:01:50,220 --> 00:01:54,330
The copy constructor copies every value from the source object into the current object.
19
00:02:07,440 --> 00:02:13,890
And now I'm fully confident that every object defines fields and all of these fields have been provided
20
00:02:13,890 --> 00:02:21,090
a value one way or another and finally noticed that both constructors are identical in the first constructor,
21
00:02:21,100 --> 00:02:26,400
we're using parameters to update each field and in the second one, we're updating each field from another
22
00:02:26,400 --> 00:02:27,010
object.
23
00:02:27,360 --> 00:02:29,070
The differences are very minor.
24
00:02:31,660 --> 00:02:37,120
In this lesson, you fixed the copy constructor, each car object has Fifield's, but the copy constructor
25
00:02:37,120 --> 00:02:40,990
was only updating four of them, so we added the extra field updates.
2710
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.