Reputation: 3850
Public Class A
Private aa As Integer
Dim bb As Integer
Public cc As Integer
End Class
Public Class B
Inherits A
Private dd As Integer
Dim ee As Integer
Public ff As Integer
End Class
Public Class C
Dim oA As New A
End Class
what is the size of the object oA?
and what if Class A and B contain methods?(I meant the size of object)
what if inherited class B contains overridden methods?(size of object)
what if inherited class B contains variables with same name as in Class A?(size of object)
I need theoretical answer. Does those access specifiers Private,Dim,Public make any difference in allocating memory because of their different scopes?
On what basis memory is allotted for a method? etc.
Upvotes: 0
Views: 295
Reputation: 1064014
oA
is a variable holding a reference, not an object; the size of a reference depends on the platform, but is generally 4 bytes on x86 and 8 bytes on x64oA
is of type A
, and has 3 integers, so the size is 12 bytes plus the standard object headerB
has 6 integers (3 directly, 3 inherited from A
); any name overlaps do not impact the fact that they exist - so the size is 24 bytes plus the standard object headerUpvotes: 2