1 00:00:05,520 --> 00:00:12,450 Why is this happening is because one of our function, that brain function was virtual function. 2 00:00:12,810 --> 00:00:18,970 So we were able to change the definition of the virtual function at that one time because it was virtual. 3 00:00:19,230 --> 00:00:25,530 So once that is inherited by the right place, it was able to bring the right brain function. 4 00:00:25,710 --> 00:00:26,070 OK? 5 00:00:26,250 --> 00:00:28,500 It was able to use the right brain function. 6 00:00:28,740 --> 00:00:35,600 But in this case, this is that function which was inherited and rupturing the show. 7 00:00:35,610 --> 00:00:37,080 It was not a virtual function. 8 00:00:37,290 --> 00:00:43,350 So even if we are putting that show off function from that right glass object, it was just printing 9 00:00:43,350 --> 00:00:44,880 the other one. 10 00:00:45,180 --> 00:00:45,560 OK? 11 00:00:45,720 --> 00:00:49,760 The base class show function, because it was not all of them. 12 00:00:49,830 --> 00:00:51,090 It was same. 13 00:00:51,670 --> 00:00:57,570 The meaning of this show function last, not getting cancer, that only this was getting answered. 14 00:00:57,900 --> 00:01:01,200 That is because that function was not declared us. 15 00:01:01,560 --> 00:01:04,450 Let's hope you have understood this concept. 16 00:01:04,890 --> 00:01:12,030 You will take some time to digest all this concept because it's a huge topic. 17 00:01:12,030 --> 00:01:19,500 And if you need more information, you can always refer to the resources section, which I will give 18 00:01:19,500 --> 00:01:26,610 in my website and you can for all those things to read as well so that you will understand more about 19 00:01:26,610 --> 00:01:27,380 this things. 20 00:01:27,600 --> 00:01:34,860 So if you have any kind of questions, please read the end of the course and I will be seeing these 21 00:01:34,860 --> 00:01:35,830 to contact me. 22 00:01:35,850 --> 00:01:38,940 So then you can put it like that. 23 00:01:39,150 --> 00:01:42,390 Get in touch with me and you can clarify your questions. 24 00:01:43,080 --> 00:01:46,990 OK, so that's all about the literature functions. 25 00:01:46,990 --> 00:01:53,570 So you have understood the concept of what a functions and what your functions are a great way to achieve 26 00:01:54,060 --> 00:01:56,850 runtime polymorphism runtime. 27 00:01:57,360 --> 00:02:03,480 Bottom line for somebody that achieved or literally blind at or our friends of based type, also based 28 00:02:03,490 --> 00:02:09,560 glass lined up can pointed objects of base class, as well as the object of the right class in their 29 00:02:09,590 --> 00:02:10,980 vocal base class. 30 00:02:10,980 --> 00:02:16,410 Bind up the PDA contain star press off Object B off the right class. 31 00:02:16,410 --> 00:02:22,620 So we are creating a if you are a member of the court, which I was showing you without creating a pointer 32 00:02:22,620 --> 00:02:28,860 off the base class for us and we were starting that press of the object of the RAM class there. 33 00:02:29,130 --> 00:02:35,640 And according to our runtime polymorphism, you have used that word, Cherokee word, and that virtual 34 00:02:35,640 --> 00:02:40,580 key word was actually showing that output for that derived class. 35 00:02:40,590 --> 00:02:48,090 While the non-material function show was not showing that output for that bay like a drive class, it 36 00:02:48,090 --> 00:02:50,950 was showing up for that base class. 37 00:02:51,000 --> 00:02:54,720 So that's the difference between base class and derived class. 38 00:02:55,080 --> 00:02:58,460 So now we move to the next topic abstract class. 39 00:02:58,470 --> 00:03:04,530 It's also a simple topic, and abstract class is a class. 40 00:03:04,710 --> 00:03:11,370 It's an automatic last week ltd in C++, but in order to make it class abstract, what we need to make 41 00:03:11,370 --> 00:03:15,090 sure that we should have at least one curatorial function. 42 00:03:15,330 --> 00:03:19,950 So then you will be thinking like, well, what will be that PR related function? 43 00:03:20,100 --> 00:03:20,400 Right? 44 00:03:20,700 --> 00:03:25,080 So the bureau will still function is a function that has no definition. 45 00:03:25,170 --> 00:03:31,350 So we will be writing a function inside our base class, but we will be giving no definition to it. 46 00:03:31,470 --> 00:03:37,440 What we will do, then we will inherit that function to it, the right class and we will be the definition 47 00:03:37,440 --> 00:03:38,400 of the function, all of that. 48 00:03:38,550 --> 00:03:40,500 So that will be the thing which will be happening. 49 00:03:40,680 --> 00:03:43,140 So as soon you will be able to see that. 50 00:03:43,560 --> 00:03:46,500 Let's go to the example of that. 51 00:03:46,650 --> 00:03:52,560 So what are we just contain at least one PR little function as far abstract class? 52 00:03:52,590 --> 00:03:57,540 OK, so let's go to the demo, then you will be getting that. 53 00:03:57,660 --> 00:04:00,690 So I have this abstract program over here. 54 00:04:01,140 --> 00:04:11,460 See, if you look out here, you can see our class size shape and that glass part rectangle and OneNote 55 00:04:11,460 --> 00:04:12,940 class on triangle. 56 00:04:13,530 --> 00:04:17,190 Here we have to compute the area of the shape. 57 00:04:17,670 --> 00:04:18,090 OK. 58 00:04:18,750 --> 00:04:23,940 Let it be triangle or let it be back then we want to remove the of the sheet. 59 00:04:24,250 --> 00:04:31,230 But why do you need to do is like if you want to come like, compile daily, appreciate each shape has 60 00:04:31,230 --> 00:04:32,190 its own formula. 61 00:04:32,580 --> 00:04:41,700 So for computing the VAT allied values of each shape, it's having a formula like four rectangle. 62 00:04:41,700 --> 00:04:45,450 It's length, the numerator in the high three and four triangle. 63 00:04:45,480 --> 00:04:50,000 It's like waiting to hide by two for most of the ranks. 64 00:04:50,140 --> 00:04:51,750 OK, I'll be. 65 00:04:51,750 --> 00:04:56,040 It's half into base into how I got ripped into high by two, right? 66 00:04:56,250 --> 00:05:00,270 So that's what we are doing actually our shape here. 67 00:05:00,270 --> 00:05:02,700 If you notice we have a class called shape. 68 00:05:03,030 --> 00:05:04,710 We have a function to set our. 69 00:05:05,110 --> 00:05:06,060 And set the height. 70 00:05:06,500 --> 00:05:12,130 OK, accepting width and height from like this argument said, then sit tight. 71 00:05:12,460 --> 00:05:13,870 And then what will happen? 72 00:05:14,180 --> 00:05:21,070 Dysfonctionnement said that between height parameters and what will happen next, we have a virtual 73 00:05:21,070 --> 00:05:29,290 function called area and see that virtual function guard area is declared inside the glass shape, but 74 00:05:29,440 --> 00:05:31,120 it is equal to zero. 75 00:05:31,430 --> 00:05:35,890 OK, that means this virtual function is not given any definition right now. 76 00:05:36,250 --> 00:05:43,150 So what we are doing is we are inheriting that shape two rectangle glass and are saying inheriting the 77 00:05:43,150 --> 00:05:45,370 same shape shaped triangular glass. 78 00:05:45,520 --> 00:05:47,530 And then we are redefining the area. 79 00:05:47,770 --> 00:05:55,150 We are defining the area function s return built into height for rectangular and return half of the 80 00:05:55,480 --> 00:05:57,040 height for diameter. 81 00:05:57,250 --> 00:06:06,490 So our function, which which was having Midwest bar area in the shape plot last not having it. 82 00:06:06,490 --> 00:06:08,170 Pure definition, OK? 83 00:06:08,290 --> 00:06:09,280 It was garden. 84 00:06:09,460 --> 00:06:11,850 It's just initialized to zero. 85 00:06:11,920 --> 00:06:18,880 So this form of initialization or this form or function sort of like pure virtual function because it's 86 00:06:18,880 --> 00:06:23,680 not having it definition if you are so yet, there is no function definition of it here. 87 00:06:23,920 --> 00:06:30,490 And one more thing is like hourglass shape is part of an abstract class because it's containing at least 88 00:06:30,490 --> 00:06:34,540 one with Japan in this area with jump function. 89 00:06:34,750 --> 00:06:42,640 So our shape glasses containing this virtual function, so it's having one part of a larger function 90 00:06:42,640 --> 00:06:43,420 inside that. 91 00:06:43,570 --> 00:06:48,280 So our shape process quite abstract as it's very simple theoretical concept. 92 00:06:48,520 --> 00:06:56,410 And now you can see on the program, we are creating two objects one for rectangle and one for triangles. 93 00:06:56,650 --> 00:07:03,280 We are setting the bit of rectangle object in the fight and height of rectangle object. 94 00:07:03,580 --> 00:07:10,930 And similarly, we are setting the width of triangle object to trendy and setting the height of triangles. 95 00:07:11,020 --> 00:07:12,480 Object two eight. 96 00:07:12,820 --> 00:07:18,100 And now we are printing it using that respective area functions. 97 00:07:18,490 --> 00:07:20,710 That was the PR function. 98 00:07:20,830 --> 00:07:23,870 Now let's see how this program will work. 99 00:07:23,890 --> 00:07:34,480 So C++ Abstract Art CPB nine now dot slash is not. 100 00:07:36,290 --> 00:07:44,410 See, we have the rectangular areas, 50, because it was doing this, then in the four feet and triangles 101 00:07:44,420 --> 00:07:49,610 area, it was passing trendy and we saw a half of twenty eight, right? 102 00:07:49,790 --> 00:07:52,620 It's a so trendy and radius 160. 103 00:07:52,820 --> 00:07:54,560 I think that values 80. 104 00:07:54,570 --> 00:07:57,890 So we have bought that two things, right? 105 00:07:58,040 --> 00:07:59,780 And what happened, actually? 106 00:07:59,880 --> 00:08:07,790 We were using the same function, which was inside the base glass, but with different formulas or definitions. 107 00:08:07,970 --> 00:08:16,370 So that's all about the abstract glass and there and a smart pick up of our bottom of this up what we 108 00:08:16,380 --> 00:08:20,240 have understood this topic so we can move to that next lecture.