Superclass inherits from a subclass. Coursera. Are they crazy? [closed]

倾然丶 夕夏残阳落幕 提交于 2019-12-13 11:12:29

问题


Learn to Program: Crafting Quality Code

Screenshot

This is a video lecture from Coursera Learn to Program Crafting Quality Code Course. So there is a quiz during the video.
class MyInt(int):
    # some code there

They gave 4 answers where I need to choose a right one. I've choose my answers one by one but finally they say that right is absolutely wrong answer.

int is a subclass of MyInt

This question Python: How do I make a subclass from a superclass? gives me absolutely right confirmation that I'am right.

Where is the truth?


回答1:


There must be something wrong with the quiz, the code as written in the question is declaring that MyInt is a subclass of int (or equivalently: that int is the superclass of MyInt), no the other way around.




回答2:


If you inherit from a class, that class is the super-class. In the example int is the super (or base) class and MyInt is the subclass. They're wrong, just as you suspected. ;-)



来源:https://stackoverflow.com/questions/15954360/superclass-inherits-from-a-subclass-coursera-are-they-crazy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!