Wednesday, October 2, 2013

Hello,

I would like to write my first topic on classes and inheritance. So we basically learned how to make a sort of abstract data type called stacks. Now I don’t really understand why we would call this abstract, because it is usually represented as a list. Here is the funny thing about stacks: the first entry in is the last one out, because as we append the material, we do so by appending to the end of a list and when we pop() a stack we just return and delete the last item of a list. A queue is the exact opposite, and instead of poping l[-1] we pop l[0].

I don’t really get why we use the latter but I do know how to implement them using classes and lists. Now here is the situation with classes, I do know how a class can inherit methods and attributes from a superclass, yet I still don’t understand what a subclass does with a method that it does not understand. Also if both the parent class and the superclass have the same methods, when called which one gets the priority.


I believe that im going to have to test this out and see whether the superclass or the subclass gets the priority.

No comments:

Post a Comment