1 00:00:05,520 --> 00:00:09,110 Okay, so now that we understand the basics of c++ pointers. 2 00:00:09,220 --> 00:00:12,299 Let's talk about one of the main use cases for pointers that 3 00:00:12,300 --> 00:00:14,110 is dynamic memory allocation. 4 00:00:15,290 --> 00:00:18,360 When we're developing software, we often have no idea how much storage 5 00:00:18,360 --> 00:00:19,959 we're going to need to model our data. 6 00:00:20,310 --> 00:00:23,419 For example, if I'm modeling the students in my class, how many 7 00:00:23,420 --> 00:00:25,280 students do I allocate storage for. 8 00:00:26,200 --> 00:00:29,150 If I'm using an array to model the students, then I need to know exactly 9 00:00:29,150 --> 00:00:33,240 how many students I have since once I allocate an array it's fixed in size. 10 00:00:33,750 --> 00:00:35,469 I know what you're thinking, hey, didn't you tell us 11 00:00:35,500 --> 00:00:38,000 earlier that we should be using vectors instead of arrays. 12 00:00:38,370 --> 00:00:39,280 Yes, I did. 13 00:00:39,380 --> 00:00:40,300 And that's still true. 14 00:00:40,500 --> 00:00:43,190 However, it's important to understand how to allocate memory 15 00:00:43,190 --> 00:00:47,280 dynamically, not just for arrays but for other data, including objects. 16 00:00:48,050 --> 00:00:50,570 Also, how do you think vectors work behind the scenes? 17 00:00:50,880 --> 00:00:54,019 They use techniques to allocate and deallocate memory from the heap. 18 00:00:54,269 --> 00:00:56,460 So we really need to understand how that works. 19 00:00:57,070 --> 00:00:59,940 In this video, I'll go over the basics of allocating memory 20 00:00:59,980 --> 00:01:01,180 dynamically from the heap. 21 00:01:01,730 --> 00:01:04,930 All memory that's allocated dynamically via a pointer comes 22 00:01:04,930 --> 00:01:06,310 from the heap or the free store. 23 00:01:07,020 --> 00:01:09,790 As I said, we'll use dynamic memory allocation again later 24 00:01:09,790 --> 00:01:13,080 in this course in the context of object-oriented objects. 25 00:01:13,480 --> 00:01:15,899 So how do you allocate storage at runtime? Let's see. 26 00:01:18,360 --> 00:01:21,570 We use the new keyword to allocate storage at runtime. 27 00:01:22,080 --> 00:01:25,830 In this example, we declare int pointer as a pointer to an integer. 28 00:01:26,320 --> 00:01:29,849 Rather than assigning the address of some integer variable, as 29 00:01:29,850 --> 00:01:33,229 we've done previously, why don't we create an integer runtime 30 00:01:33,240 --> 00:01:37,420 that's on the heap and store that variables addressed in int pointer. 31 00:01:38,090 --> 00:01:38,990 That's pretty cool. 32 00:01:39,260 --> 00:01:40,630 You can see how easy it is. 33 00:01:40,639 --> 00:01:43,270 Int pointer equals new int, that's it. 34 00:01:43,280 --> 00:01:44,159 That's all it takes. 35 00:01:44,539 --> 00:01:47,630 This allocates storage for an integer on the heap and stores 36 00:01:47,630 --> 00:01:49,440 its address in int pointer. 37 00:01:50,080 --> 00:01:52,390 Now we can use the pointer to access the integer. 38 00:01:53,120 --> 00:01:56,220 The first output statement displays the value of int pointer. 39 00:01:56,550 --> 00:01:59,030 This is the address of the newly created integer. 40 00:01:59,490 --> 00:02:02,770 If we want to get to that integer, we need to dereference the pointer. 41 00:02:03,580 --> 00:02:07,039 But notice what gets displayed: a really large integer value. 42 00:02:07,330 --> 00:02:10,508 That's because the integer that was allocated hasn't been initialized 43 00:02:10,508 --> 00:02:12,530 yet and it contains garbage data. 44 00:02:13,130 --> 00:02:17,049 So in order to assign a value to that integer on the heap, we dereference 45 00:02:17,050 --> 00:02:20,710 the pointer to get to the integer and then store 100 in it in this case. 46 00:02:21,240 --> 00:02:23,769 Now when we display the value of the integer, we get back 47 00:02:23,779 --> 00:02:25,240 100, that's pretty cool. 48 00:02:25,670 --> 00:02:27,090 A couple of things to understand. 49 00:02:27,510 --> 00:02:30,190 When you allocate storage in this manner, the storage is on 50 00:02:30,190 --> 00:02:33,910 the heap, the allocated storage contains garbage data until you 51 00:02:33,910 --> 00:02:37,889 initialize it. The allocated storage does not have a name. 52 00:02:37,900 --> 00:02:40,669 The only way to get to that storage is via the pointer. 53 00:02:41,170 --> 00:02:43,910 If you lose the pointer because it goes out of scope or you 54 00:02:43,920 --> 00:02:47,410 reassign it, then you lost your only way to get to that storage 55 00:02:47,440 --> 00:02:48,660 and you have a memory leak. 56 00:02:48,860 --> 00:02:50,210 I'll talk more about that later. 57 00:02:51,070 --> 00:02:54,580 Finally, when you're done using the storage, then you must de-allocate 58 00:02:54,580 --> 00:02:57,730 the storage, so that it's again available to the rest of the program. 59 00:02:57,809 --> 00:02:58,790 Let's see how. 60 00:03:00,719 --> 00:03:03,079 Here you see that we again have declared int pointer is 61 00:03:03,140 --> 00:03:06,720 a pointer to an int, then we assign new int to int pointer. 62 00:03:07,170 --> 00:03:09,780 This statement allocates storage for an integer on the heap and 63 00:03:09,780 --> 00:03:12,989 stores the address of that integer in int pointer, just like before. 64 00:03:13,820 --> 00:03:15,509 We can use the pointer as we wish. 65 00:03:15,820 --> 00:03:19,019 And then when we're done, we need to release or deallocate the storage 66 00:03:19,029 --> 00:03:20,950 that we allocated for that integer. 67 00:03:21,620 --> 00:03:24,810 We can do that easily using the delete keyword followed 68 00:03:24,810 --> 00:03:26,190 by the name of the pointer. 69 00:03:26,550 --> 00:03:30,119 Make sure that the address in the pointer is an address of storage 70 00:03:30,119 --> 00:03:31,669 that was allocated using new. 71 00:03:34,279 --> 00:03:37,739 We just saw an example of allocating a single integer dynamically. 72 00:03:38,220 --> 00:03:41,190 You can do the same with doubles, strings, vectors and so forth. 73 00:03:41,550 --> 00:03:43,670 But in this slide, we'll do something a little more useful 74 00:03:43,670 --> 00:03:45,250 than allocating a single integer. 75 00:03:45,650 --> 00:03:48,859 How about we allocate an entire array of integers on the heap at runtime? 76 00:03:50,090 --> 00:03:53,399 In the sample code, we declare a pointer to an integer called array 77 00:03:53,410 --> 00:03:56,090 pointer and an integer named size. 78 00:03:56,500 --> 00:03:58,980 We ask the user how big they want the array to be? 79 00:03:59,260 --> 00:04:01,660 This could be the number of scores on an exam or the number of 80 00:04:01,660 --> 00:04:03,269 temperatures to read and so forth. 81 00:04:03,980 --> 00:04:06,890 Then we use the new operator with square brackets this time 82 00:04:07,170 --> 00:04:10,149 and the number of elements to allocate inside the brackets. 83 00:04:10,840 --> 00:04:13,800 This will attempt to allocate that many integers on the 84 00:04:13,800 --> 00:04:15,790 heap contiguously in memory. 85 00:04:16,610 --> 00:04:20,100 If the storage is successfully created, then the address of the first 86 00:04:20,110 --> 00:04:22,140 integer is stored in array pointer. 87 00:04:22,580 --> 00:04:23,440 That's pretty easy. 88 00:04:23,920 --> 00:04:25,950 Of course, when we're done with the memory, we need to 89 00:04:25,950 --> 00:04:27,380 release it or deallocate it. 90 00:04:27,700 --> 00:04:29,189 Let's see the syntax for that. 91 00:04:32,889 --> 00:04:36,320 Here's the same code example, but the last statement deletes the entire 92 00:04:36,320 --> 00:04:38,170 array that we allocated dynamically. 93 00:04:38,639 --> 00:04:41,979 Notice the square brackets between the delete and the name of the pointer. 94 00:04:42,340 --> 00:04:43,930 These brackets must be empty. 95 00:04:43,930 --> 00:04:46,140 Do not include anything inside the brackets. 96 00:04:46,670 --> 00:04:51,550 Okay, let's go to the IDE and create some storage dynamically. 97 00:04:51,550 --> 00:04:54,840 Okay, so I'm in the IDE, I'm in the section 12 workspace 98 00:04:54,920 --> 00:04:56,690 in the dynamic memory project. 99 00:04:57,389 --> 00:05:00,289 What I want to do in this little example is allocate a 100 00:05:00,290 --> 00:05:02,009 single element on the heap. 101 00:05:02,009 --> 00:05:06,800 In this case, we'll do an integer and point to it from a pointer. 102 00:05:07,150 --> 00:05:09,909 Okay, and we're going to use the new keyword to do that. 103 00:05:09,909 --> 00:05:12,880 And then after that, we'll allocate storage for an array, 104 00:05:12,880 --> 00:05:14,090 like we did with the slides. 105 00:05:14,410 --> 00:05:15,849 All right, so let's do this first. 106 00:05:16,630 --> 00:05:17,639 We need a pointer. 107 00:05:17,639 --> 00:05:19,179 We need a pointer to an integer. 108 00:05:19,349 --> 00:05:21,579 And you know what, before we do that, let's let's talk about 109 00:05:21,580 --> 00:05:22,790 exactly what's going on here. 110 00:05:23,809 --> 00:05:28,020 If you remember when we talked about our memory model earlier, we've got 111 00:05:28,020 --> 00:05:32,100 our memory model here where we've got our code is down here. Then we 112 00:05:32,100 --> 00:05:37,210 had our global variables, and then we had our stack right here, right. 113 00:05:37,240 --> 00:05:40,479 And our stack is where the function calls happen. 114 00:05:40,480 --> 00:05:43,229 And this is push pop, so we're pushing and popping activation 115 00:05:43,230 --> 00:05:44,910 records on here, just like before. 116 00:05:45,220 --> 00:05:48,090 Well, we also have a part of memory called the heap. 117 00:05:48,550 --> 00:05:49,970 It's also called the free store. 118 00:05:52,110 --> 00:05:55,019 All dynamic allocation happens here. 119 00:05:56,359 --> 00:05:59,540 Okay, we can't really do dynamic allocation on the stack. 120 00:05:59,549 --> 00:06:02,169 It's already doing dynamic allocation when we push 121 00:06:02,170 --> 00:06:04,290 and pop activation records. 122 00:06:04,820 --> 00:06:08,460 But we can't really decide at runtime how big those things are going to be. 123 00:06:08,940 --> 00:06:10,710 We can to a point, but not really. 124 00:06:11,080 --> 00:06:12,640 The heap is a free-for-all. 125 00:06:12,700 --> 00:06:14,379 We've got a whole bunch of memory out there. 126 00:06:14,380 --> 00:06:19,000 We can request that we get a 1000 integers, 2000 integers, 127 00:06:19,000 --> 00:06:20,370 15 objects as much as we want. 128 00:06:21,130 --> 00:06:23,820 But we need to take care of that heap, and we need to release 129 00:06:23,850 --> 00:06:24,950 the storage when we're done. 130 00:06:25,190 --> 00:06:26,620 So that's the kind of thing we'll do here. 131 00:06:26,960 --> 00:06:29,650 Now what I want to do is I want to create an integer pointer 132 00:06:31,700 --> 00:06:34,020 that's going to be in main, so it's going to be on the stack. 133 00:06:34,299 --> 00:06:36,630 And I want to allocate an integer on the heap. 134 00:06:36,630 --> 00:06:39,770 So I want to allocate an integer dynamically on the heap, and I want 135 00:06:39,770 --> 00:06:41,390 to point to it from that pointer. 136 00:06:42,670 --> 00:06:44,200 Okay, that's what I want to do first. 137 00:06:44,470 --> 00:06:48,599 Then what I want to do is I want to allocate an array of doubles, let's 138 00:06:48,599 --> 00:06:53,020 say, in this case on the heap again. 139 00:06:53,279 --> 00:06:54,430 And how big is it going to be? 140 00:06:54,520 --> 00:06:56,740 I don't know. I'm going to ask the user how many doubles they need. 141 00:06:57,320 --> 00:07:00,920 And then what we'll have is we'll have a pointer two doubles in this 142 00:07:00,920 --> 00:07:03,720 case, that's going to point to there. 143 00:07:04,870 --> 00:07:06,550 Okay, so that's what we're going to do. 144 00:07:06,639 --> 00:07:08,910 Let's start here, let's do the integer first. 145 00:07:09,020 --> 00:07:12,359 We need a pointer to it, so we're going to have an integer. 146 00:07:14,150 --> 00:07:15,900 And we'll initialize it to null pointer. 147 00:07:15,900 --> 00:07:17,270 That's our best practice. 148 00:07:17,590 --> 00:07:19,830 So what we've done now is we've got a variable. 149 00:07:19,850 --> 00:07:22,150 Remember, it's a variable called int pointer that points 150 00:07:22,150 --> 00:07:24,930 to an integer, so it's going to hold addresses of integers. 151 00:07:25,160 --> 00:07:26,580 Right now, it's pointing nowhere. 152 00:07:27,610 --> 00:07:32,030 If we want to allocate this dynamically at runtime from the heap, 153 00:07:32,240 --> 00:07:38,460 we just say int pointer equals new and then followed by the type that I 154 00:07:38,460 --> 00:07:40,320 want to allocate, in this case, int. 155 00:07:42,059 --> 00:07:45,189 Now what's going to happen is that storage for an integer is going to 156 00:07:45,190 --> 00:07:49,510 be allocated on the heap, and its address will be stored in int pointer. 157 00:07:50,710 --> 00:07:56,750 Okay, so we can just do something like display int pointer, and that 158 00:07:56,750 --> 00:08:00,840 will display the memory location where that integer is on the heap. 159 00:08:00,960 --> 00:08:03,499 Remember, that's the address that's stored in int pointer. 160 00:08:03,929 --> 00:08:07,920 Okay, so let's run that, and you can see that then hex address 161 00:08:07,940 --> 00:08:12,360 right there, that's where that integer lives on the heap, and 162 00:08:12,360 --> 00:08:13,840 our pointer is not pointing to it. 163 00:08:14,300 --> 00:08:16,780 It's important to understand that, that integer that we just 164 00:08:16,790 --> 00:08:18,570 created on the heap has no name. 165 00:08:19,259 --> 00:08:22,179 There's no way to get to it except through this pointer. 166 00:08:22,389 --> 00:08:25,740 So if I lose the pointer, I've got something called a memory leak, which 167 00:08:25,740 --> 00:08:27,230 I'll talk a little bit about later. 168 00:08:27,950 --> 00:08:31,469 So at this point, we can use this integer, however, we like. 169 00:08:31,500 --> 00:08:33,500 And when we're done, we need to delete it. 170 00:08:33,870 --> 00:08:37,448 So the syntax for that is simply the keyword delete, followed by 171 00:08:37,450 --> 00:08:41,399 the name of the pointer, which, in this case, is int pointer, 172 00:08:43,940 --> 00:08:45,310 that frees up the storage. 173 00:08:46,270 --> 00:08:47,650 Okay, so pretty easy. 174 00:08:48,510 --> 00:08:50,109 Now what we'll do is -- let me clean up a little bit 175 00:08:50,110 --> 00:08:51,259 of this white space here. 176 00:08:52,960 --> 00:08:56,689 Now what we'll do is we'll create a whole contiguous 177 00:08:56,690 --> 00:08:58,220 block of memory on the heap. 178 00:08:58,619 --> 00:09:00,519 Okay, and we'll do doubles this time. 179 00:09:00,860 --> 00:09:02,020 So there's two things here. 180 00:09:02,020 --> 00:09:04,650 We don't know the size, so we have to ask the user how 181 00:09:04,650 --> 00:09:05,870 many doubles do you need. 182 00:09:07,020 --> 00:09:09,690 And we also need a pointer to that area, so we declare 183 00:09:09,690 --> 00:09:10,689 both of those right now. 184 00:09:11,070 --> 00:09:14,709 The size will declare it as a size type, and we'll just call it 185 00:09:14,710 --> 00:09:16,549 size, we'll initialize it to zero. 186 00:09:18,230 --> 00:09:21,410 And the pointer will be a pointer to doubles. 187 00:09:22,170 --> 00:09:24,449 And the name of the pointer, let's just say, temp pointer, 188 00:09:24,449 --> 00:09:25,710 so it'll be like temperatures. 189 00:09:26,740 --> 00:09:29,680 And again, we'll initialize it to null. 190 00:09:30,730 --> 00:09:31,880 So we're good to go here. 191 00:09:32,280 --> 00:09:33,550 So let's ask the user. 192 00:09:33,889 --> 00:09:36,640 So we'll ask the user we'll say how many temps, 193 00:09:38,240 --> 00:09:39,720 right, how many temperatures do they need. 194 00:09:40,060 --> 00:09:41,599 And we'll read that into size. 195 00:09:42,570 --> 00:09:44,740 So now we know how many temperatures to allocate. 196 00:09:44,929 --> 00:09:49,209 So if they typed in 50 100 200 10,000, whatever they typed in, that's how 197 00:09:49,210 --> 00:09:50,589 much storage we're going to allocate. 198 00:09:51,559 --> 00:09:52,359 So what do we do? 199 00:09:52,440 --> 00:09:53,470 We use the pointer. 200 00:09:53,500 --> 00:09:58,620 We're going to say temp pointer equals new, what am I allocating? 201 00:09:58,710 --> 00:10:00,700 Well, I'm allocating doubles, in this case. 202 00:10:01,100 --> 00:10:03,080 And how many size? 203 00:10:03,440 --> 00:10:06,350 This is where you put the size in the square brackets. 204 00:10:07,420 --> 00:10:11,049 That's going to allocate that chunk of memory, happens to be an array in this 205 00:10:11,049 --> 00:10:15,170 case because it's contiguous doubles in memory and store the address 206 00:10:15,170 --> 00:10:16,700 of the first one into temp pointer. 207 00:10:18,130 --> 00:10:19,970 Okay, so at this point we can say cout. 208 00:10:21,840 --> 00:10:24,269 Let's just say temp pointer, see what's in there? 209 00:10:25,450 --> 00:10:27,579 Obviously, it's an address of that first double, right. 210 00:10:28,199 --> 00:10:30,139 And let's run that real quick see what we get. 211 00:10:30,900 --> 00:10:31,689 So how many temps? 212 00:10:31,690 --> 00:10:32,810 Let's say 100 temperatures. 213 00:10:33,500 --> 00:10:36,460 And you can see right there that's the area in the heap 214 00:10:36,900 --> 00:10:40,760 that contains the address of the first of those 100 doubles. 215 00:10:41,469 --> 00:10:42,049 Pretty easy. 216 00:10:43,270 --> 00:10:44,479 Now when we're done, what do we do? 217 00:10:44,480 --> 00:10:46,979 We always need to free up the space that we allocated. 218 00:10:47,250 --> 00:10:51,540 So we can say delete, in this case, we allocated an array right there. 219 00:10:51,540 --> 00:10:54,380 You've got the square brackets in the new call, so here you've got to put 220 00:10:54,380 --> 00:10:55,930 the square brackets and the delete. 221 00:10:56,260 --> 00:10:59,900 Nothing inside the square brackets and then the name of the pointer 222 00:10:59,980 --> 00:11:01,070 which was temperature pointer. 223 00:11:03,139 --> 00:11:03,950 That's it. 224 00:11:04,020 --> 00:11:05,449 That's the entire program. 225 00:11:05,699 --> 00:11:07,740 And you can see what's happening at this point, right. 226 00:11:07,990 --> 00:11:10,720 What we did was we had and I'm not going to draw the whole stack 227 00:11:10,720 --> 00:11:15,370 again, but we had that temp pointer right here that was on the stack. 228 00:11:16,460 --> 00:11:23,590 We allocated, let's say, 100 doubles on the heap. Temp pointer 229 00:11:23,590 --> 00:11:25,210 is pointing to the first one. 230 00:11:26,190 --> 00:11:27,830 Okay, that's really what's happening. 231 00:11:27,830 --> 00:11:28,840 This is on the heap. 232 00:11:29,870 --> 00:11:32,800 And in this case, temp pointer was on the stack because it's 233 00:11:32,809 --> 00:11:34,210 local to main right here. 234 00:11:35,719 --> 00:11:38,570 Notice what happens if we lose this pointer, I mean if we do something 235 00:11:38,570 --> 00:11:47,770 really silly like, I don't know, temp pointer equals null pointer, right. 236 00:11:47,770 --> 00:11:50,150 And we do that before we did this, and what just happened? 237 00:11:50,150 --> 00:11:51,929 Well, we just nulled out this pointer. 238 00:11:52,130 --> 00:11:53,269 So this is gone. 239 00:11:53,270 --> 00:11:56,069 We just lost our only way to get to that storage. 240 00:11:56,640 --> 00:11:58,030 And that's called the memory leak. 241 00:11:59,119 --> 00:12:03,010 What the delete call does is it frees up this storage again. 242 00:12:03,020 --> 00:12:05,430 Your pointer is still pointing to it, and that's important because 243 00:12:05,430 --> 00:12:08,350 if you try to use that pointer again after you've deleted the 244 00:12:08,350 --> 00:12:11,280 storage, you could have really, really unpredictable results. 245 00:12:11,280 --> 00:12:14,959 But in this case, you don't want to lose your pointer to a 246 00:12:14,999 --> 00:12:18,480 dynamically allocated memory because then it's basically orphaned out 247 00:12:18,480 --> 00:12:20,050 there, and that's the memory leak. 248 00:12:20,900 --> 00:12:24,849 Okay, now let's see what happens if our call fails. 249 00:12:25,710 --> 00:12:27,559 Our call to allocate the size here. 250 00:12:27,910 --> 00:12:30,740 Now I'll do something that you should never do. 251 00:12:30,900 --> 00:12:32,840 But I'm going to create an endless loop here. 252 00:12:33,240 --> 00:12:37,999 I'm just going to say while true allocate that. 253 00:12:38,029 --> 00:12:39,689 So this is going to -- I'm going to ask you how many 254 00:12:39,690 --> 00:12:40,770 temperatures you want to allocate? 255 00:12:40,770 --> 00:12:42,580 I'm going to type something like 10000. 256 00:12:43,210 --> 00:12:47,040 And then what I'll do is I'll just keep looping allocating and creating 257 00:12:47,040 --> 00:12:48,379 memory leaks all over the place. 258 00:12:49,000 --> 00:12:51,509 Eventually, we're going to run out of memory and the heap. 259 00:12:51,730 --> 00:12:54,480 So eventually, this will fail, and I should get an exception. 260 00:12:55,049 --> 00:12:56,480 So let's see what that looks like. 261 00:12:58,690 --> 00:13:02,730 How many times, let's say, a lot. 262 00:13:03,639 --> 00:13:05,620 I remember it's going to be in an infinite loop doing 263 00:13:05,620 --> 00:13:06,600 this over and over and over. 264 00:13:07,330 --> 00:13:07,989 And there you go. 265 00:13:07,990 --> 00:13:08,950 That was pretty fast. 266 00:13:09,380 --> 00:13:11,630 You can see terminate called after throwing an instance 267 00:13:11,630 --> 00:13:13,040 of standard bad alloc. 268 00:13:13,270 --> 00:13:16,850 So basically what happened was the call to new failed. 269 00:13:16,850 --> 00:13:18,550 There was no more memory available. 270 00:13:18,910 --> 00:13:20,760 And this is the exception that's thrown. 271 00:13:21,200 --> 00:13:23,939 We'll talk about exception handling a little bit later in the class, but 272 00:13:23,960 --> 00:13:26,679 what you want to do is you want to catch that exception, you don't want 273 00:13:26,700 --> 00:13:28,639 your program to just stop like that. 274 00:13:28,639 --> 00:13:30,089 You want to catch the exception. 275 00:13:30,090 --> 00:13:33,380 And if you can deal with it somehow, maybe you've got you know 276 00:13:33,430 --> 00:13:37,090 memory and caches and temporary stuff that you can free up to 277 00:13:37,090 --> 00:13:39,859 free up some memory, and then you can reallocate this memory 278 00:13:39,860 --> 00:13:41,250 again, trying to call new again. 279 00:13:41,410 --> 00:13:43,646 So this is -- again, I'm going to delete that. 280 00:13:43,830 --> 00:13:44,900 That's not a good idea. 281 00:13:46,000 --> 00:13:48,629 But that's basically it. In the next video, we'll talk 282 00:13:48,639 --> 00:13:51,980 about the relationship between arrays, which is really what's 283 00:13:51,980 --> 00:13:53,220 going on here and a pointer. 284 00:13:53,230 --> 00:13:55,810 You can see, they're really almost the same thing here in this case. 285 00:13:56,130 --> 00:14:01,639 And how we can actually use that array that's on the heap from our code. 286 00:14:02,240 --> 00:14:03,420 So I'll be right back.