So, while I'm not building a project that requires inheritance, I think it's time I at least start to wrap my head around the concept: Consider the following code, (python)
class test_class: def __init__(self): self.x=2 self.y=4 self.z=3 def add_xnumber(self,num): self.x+=num def multiply_xnumber(self,num): self.x*=num class second_test_class(testing_class): pass
The code above is dumb and pointless, but it does show my question in much more detail. What happened when I typed second_test_class(test_class)? Here's what I know about inheritance so far. Basically, it's like having a kid... without a second parent of course. What does the kid inherit? Does he invent the entirety of his dad's DNA (all the functions of the test_class)? Does he inherit the test_class's constructor? Can I have another constructor within my second class even though it already has one from inheritance? How many classes can I inherit from? How deep can the relationship go? I.e, if I do class third_test_class(second_test_class) will I inherit the second class's functions and the base constructor of test_class? Finally, what does super() mean in python? When typing it into the prompt, I see that it is of type super, and super.__doc__ doesn't make sense.
I've tried looking up tutorials, but all of the ones I've found didn't quite explain all of my questions, so I'm hoping that'll change here.
What is hard is making code that accepts different and sometimes unexpected types of input and still works.
This is what truly takes a large amount of effort on a developer's part.