Hook
More breakout videos from this creator.
Twin you can't put a switch on the revolver but you can put a switch on a glock. And this is why we got OOPs, object oriented programming languages. See look, if we create a class called blick, we see every blick has a name and it has an ammo count. And in this class we create a function called shoot to shoot our blick. But we just shooting it regularly, we don't got a switch on it. And we create two blicks, a revolver with an ammo count of six and a G17 with an ammo count of seventeen. And if we put the shoot function on each blick, you see we run a program and every time we pull it, it shoots. It runs with the revolver and the glock. But twin look, if we create a class called blick switch and in the parenthesis we put blick, this means the blick switch class will inherit everything from the blick class. I'm gonna make it make sense. We got an import time and in our new class we're gonna create a function called switch, we're gonna write the code in there for it. And when we created our glock, we're gonna change that class right there to blick switch. They wanna go ahead and put a switch on the glock, and you see when we run it, it starts spraying. But if we put a switch on a revolver and try to run it, we see it don't work. If we put the shoot function back on the glock, we see it still works because something called inheritance. An inheritance means that one class can use stuff from another class. So our subclass blick switch could use stuff from just the blick class. So when you try to put a switch on a revolver, this is why I told you.