+ 2

Why cant we use super() functions for attributes but for the inherited class?

23rd Jul 2017, 8:09 PM
Shrikant Narvekar
Shrikant Narvekar - avatar
5 Antworten
+ 3
super() calls a function of the parent class, so it won't work attributes that aren't in the parent class.
23rd Jul 2017, 9:13 PM
ChessMaster
ChessMaster - avatar
+ 1
If you override a method of the superclass, you could call super.methodName. Just so, it would be obviously senseless, but if you want to take the superclass' method and add some stuff to it, it's kind of useful. You can do stuff and call then the parent's class method.
24th Jul 2017, 12:49 PM
Jonas Schröter
Jonas Schröter - avatar
0
Super() calls the constructor of the super class. Properties or methods do not have a super class because they belong to the class they are in.
23rd Jul 2017, 9:12 PM
josh mizzi
josh mizzi - avatar
0
The correct terminology is method. Function refers to procedural programming.
23rd Jul 2017, 9:15 PM
josh mizzi
josh mizzi - avatar
0
🤔
24th Jul 2017, 6:21 AM
Wei
Wei - avatar