0

Why is child = Child() nessasary?

See comments, is this just convention or for readability? This was an example code snippit illistrating classes https://code.sololearn.com/c5psb57Pb0qy/?ref=app https://code.sololearn.com/c5psb57Pb0qy/?ref=app

25th Sep 2017, 12:43 AM
Bridget McKenzie
5 ответов
0
I see, but why do you need to name it anything at all?
25th Sep 2017, 4:15 AM
Bridget McKenzie
0
Oh thank you, that makes sense now! Sorry for late reply!
27th Sep 2017, 12:25 AM
Bridget McKenzie
- 1
class parent is the first class class child(parent) is the 2nd defined class inherited from parent class.. ## the features parent have ; child will have too now child=child() means...child is a variable of child() class type u can name it anything...like abc=child() here we are injecting all properties of class child() in abc
25th Sep 2017, 4:13 AM
sayan chandra
sayan chandra - avatar
- 1
see.... in object oriented programming . we have a hell lot of variables... they have different but some of alike properties... so we have suppose 60 variables... how would u inject all needed properties in them... here we make certain class... certain inherited class and make the variables as they are of that class... ## hope u now get that ## once they are injected of certain class properties... we can use them in the further more codes
25th Sep 2017, 4:19 AM
sayan chandra
sayan chandra - avatar
- 1
and....this two are different things .... Child().hello()........1 child = Child() child.hello()............2 1 is just accessing hello method of Child class 2 is making a var of Child class and then using the property of that variable... now hello is a property / feature of whatever variable u named it..(abc or child)
25th Sep 2017, 4:22 AM
sayan chandra
sayan chandra - avatar