1
00:00:00,410 --> 00:00:01,700
Hello, my name is Stephan.

2
00:00:01,700 --> 00:00:05,940
And in this lecture of our course, we will continue our project on ADTs.

3
00:00:05,960 --> 00:00:07,340
So let's get started.

4
00:00:19,240 --> 00:00:23,440
So we will add a virtual method named Makesound.

5
00:00:23,440 --> 00:00:30,970
And the virtual method is a method that has no implementation yet and only has the definition.

6
00:00:31,000 --> 00:00:32,290
Also known as the interface.

7
00:00:32,290 --> 00:00:39,640
So the derived class has to add the implementation to the virtual method using the override keyword.

8
00:00:39,640 --> 00:00:42,760
So or else the compiler will complain about it.

9
00:00:42,760 --> 00:00:50,260
So after we have a new animal class, we will make a class named dog that derives from the animal class.

10
00:00:50,470 --> 00:00:57,010
So here we will add the animal here.

11
00:00:57,310 --> 00:00:59,200
So after that we will.

12
00:00:59,200 --> 00:01:00,250
As you can see, we have.

13
00:01:01,270 --> 00:01:02,230
This animal.

14
00:01:04,120 --> 00:01:10,420
And we have the constructor get give name and get name so we don't actually need the give name here

15
00:01:10,420 --> 00:01:17,500
since we are giving name using the constructor here, but we can also use that in case if in if we need

16
00:01:17,500 --> 00:01:17,620
it.

17
00:01:17,620 --> 00:01:19,390
But we don't need it for now.

18
00:01:20,230 --> 00:01:26,070
And after that we will create a new class class here, dog.

19
00:01:26,080 --> 00:01:29,470
And this is we're going to make it the public class.

20
00:01:33,140 --> 00:01:36,320
Public, actually.

21
00:01:37,140 --> 00:01:44,370
Yes, we will make it a public class so the class dog will implement the public animal.

22
00:01:44,670 --> 00:01:46,620
Public animal.

23
00:01:47,360 --> 00:01:52,130
And after that we will write our class.

24
00:01:52,160 --> 00:01:58,430
So in this case, we're going to use the public keyword and we will forward the constructor arguments.

25
00:01:58,430 --> 00:02:06,440
So the dog here, we're going to use the string name and here we're going to use the.

26
00:02:07,460 --> 00:02:08,420
Animal name.

27
00:02:08,930 --> 00:02:10,040
Animal and name.

28
00:02:10,040 --> 00:02:17,330
We will forward this the string name to our animal name here.

29
00:02:17,330 --> 00:02:21,170
So animal name and here.

30
00:02:22,950 --> 00:02:27,150
After that, we will also need to implement the interface.

31
00:02:27,150 --> 00:02:35,310
So here we're going to make the string here, make sound, make sound and we will it.

32
00:02:36,370 --> 00:02:39,410
And the sound is going to be, of course, the woof, woof.

33
00:02:39,460 --> 00:02:44,620
Like this is what the dog sound like when they are woof, woof here.

34
00:02:45,230 --> 00:02:49,010
So here we will use a return.

35
00:02:49,220 --> 00:02:50,270
Woof, woof.

36
00:02:52,380 --> 00:02:53,160
Wolf, here.

37
00:02:53,790 --> 00:02:56,130
And as you can see, we got an error here.

38
00:02:56,280 --> 00:03:01,230
So a virtual member can be marked override here.

39
00:03:01,620 --> 00:03:03,060
So now.

40
00:03:04,820 --> 00:03:05,800
No problem here.

41
00:03:06,610 --> 00:03:07,180
Obviously.

42
00:03:08,960 --> 00:03:12,110
And this is because the string makes sound.

43
00:03:12,150 --> 00:03:15,980
All right, Here, we'll have to return Wufoo and make it like that.

44
00:03:16,550 --> 00:03:17,780
And here.

45
00:03:23,570 --> 00:03:26,480
Class dog public here.

46
00:03:26,480 --> 00:03:29,240
And this is going to return the woof woof here.

47
00:03:30,620 --> 00:03:32,480
Now we will write it like that.

48
00:03:33,170 --> 00:03:35,810
We're going to create a new class named Doc here.

49
00:03:36,140 --> 00:03:41,480
Doc is going to be let's name our doc is the.

50
00:03:42,400 --> 00:03:42,910
Here.

51
00:03:43,930 --> 00:03:45,160
Hound here.

52
00:03:46,950 --> 00:03:49,350
And see out.

53
00:03:51,010 --> 00:03:52,660
Dot get name.

54
00:03:53,940 --> 00:03:58,860
Get name is gonna be is barking.

55
00:03:59,880 --> 00:04:00,900
So.

56
00:04:00,900 --> 00:04:01,740
And after that.

57
00:04:01,740 --> 00:04:04,890
See out, See out.

58
00:04:08,580 --> 00:04:10,890
Dog not make sound.

59
00:04:11,850 --> 00:04:12,240
Of course.

60
00:04:12,240 --> 00:04:13,710
It's the Maxent.

61
00:04:13,740 --> 00:04:16,560
We'll return the woof woof here.

62
00:04:16,710 --> 00:04:24,150
So make sound is going to be, uh, the Our hound is barking and woof, woof.

63
00:04:24,180 --> 00:04:24,630
Here.

64
00:04:27,540 --> 00:04:29,280
We have a problem here.

65
00:04:31,250 --> 00:04:35,560
We have string name and animal we passed here.

66
00:04:36,550 --> 00:04:38,260
Which is gonna to overeat.

67
00:04:43,210 --> 00:04:48,910
And here we will add the virtual interface in our.

68
00:04:48,910 --> 00:04:54,920
As you can see, we have an error here and we will add the virtual interface to our animal class.

69
00:04:54,940 --> 00:05:01,290
So now after the animal constructor here, we will add the virtual virtual string.

70
00:05:01,300 --> 00:05:07,390
So we, we can also use the integer because but we will get an error because this returns string here.

71
00:05:07,390 --> 00:05:10,810
So we need to use the virtual type here.

72
00:05:10,840 --> 00:05:16,540
The string and the string is going to be makesound.

73
00:05:17,630 --> 00:05:21,110
So the interface has the implemented in derived class here.

74
00:05:21,290 --> 00:05:24,560
So zero for example.

75
00:05:24,710 --> 00:05:26,810
And here.

76
00:05:28,010 --> 00:05:28,460
We have.

77
00:05:29,450 --> 00:05:34,680
So actually now we can also run our application now and see.

78
00:05:34,700 --> 00:05:36,890
As you can see, Hound is barking.

79
00:05:36,920 --> 00:05:38,030
Woof, woof here.

80
00:05:38,210 --> 00:05:42,640
So now we have two classes, the animal class here, actually.

81
00:05:42,650 --> 00:05:53,350
Let's see here we have the animal class as the base class, and we have the dog class as a derived class.

82
00:05:53,360 --> 00:06:00,770
So as shown here, the dog class has to implement the make sound method.

83
00:06:00,860 --> 00:06:07,940
And it has been defined as a virtual method here in the animal class.

84
00:06:07,940 --> 00:06:09,410
So if we delete this.

85
00:06:11,720 --> 00:06:13,970
And as you can see, we got an error here.

86
00:06:15,290 --> 00:06:16,820
We can create the haunt here.

87
00:06:18,170 --> 00:06:18,650
So.

88
00:06:22,440 --> 00:06:32,010
And the instance of the dog class can also invoke the getName method, even though it's not implemented

89
00:06:32,010 --> 00:06:40,020
inside the dog class, since derived class derives all the class behavior to itself.

90
00:06:40,380 --> 00:06:47,520
So if you run this code again, we will see this output here.

91
00:06:47,520 --> 00:06:50,020
So let's actually compile and run inside here.

92
00:06:51,540 --> 00:07:01,050
CLS or plus plus Main.cpp output dog dot x and dog dot x here.

93
00:07:01,050 --> 00:07:04,440
And as you can see here, hound is barking.

94
00:07:04,440 --> 00:07:05,190
Woof, woof.

95
00:07:05,190 --> 00:07:05,570
Here.

96
00:07:06,530 --> 00:07:08,000
Uh, that's our.

97
00:07:08,010 --> 00:07:15,660
And again, we can say that the dog ADT has two functions and they are the these are the two functions.

98
00:07:15,660 --> 00:07:18,990
They are getName and make sound functions.

99
00:07:18,990 --> 00:07:25,920
But as you can see, we have no getName functions inside the animal class and the.

100
00:07:27,120 --> 00:07:31,510
Another necessary comment will be discussed in next lecture about ADT.

101
00:07:31,580 --> 00:07:33,720
So I'm waiting you in next lecture.
