Hello,
I was wondering the cost of creating an instance of an extended class.
By that I mean, if I have classes:
- A
- A1 and A2,
where: A1 and A2 extend class A.
what do instances A1 and A2 share of their common parent A in memory?
a) Nothing
b) Attributes
c) just Methods
d) Attributes and Methods
by that I would like to know what has to be put in memory again?
My guess is c) but I don't know for sure, and I think that I also depends on the lifetime of the two instances, if they overlap or not. If they don't everything has to be put in to memory again... doesn't it?
And by the way, when I create two instances of the same class do they share the same amount of data than two subclasses with their parent (example above)?
Thanks
Regards,
bilibytes
I was wondering the cost of creating an instance of an extended class.
By that I mean, if I have classes:
- A
- A1 and A2,
where: A1 and A2 extend class A.
what do instances A1 and A2 share of their common parent A in memory?
a) Nothing
b) Attributes
c) just Methods
d) Attributes and Methods
by that I would like to know what has to be put in memory again?
My guess is c) but I don't know for sure, and I think that I also depends on the lifetime of the two instances, if they overlap or not. If they don't everything has to be put in to memory again... doesn't it?
And by the way, when I create two instances of the same class do they share the same amount of data than two subclasses with their parent (example above)?
Thanks
Regards,
bilibytes
Comment