-
메모리의 특징 이해하기C# 2019. 6. 10. 19:16
The most important 3 parts of Memories are static, stack, heap.
static is a blueprint, also called class domain. Value(block value memory, value memory, operation)domain, Heap domain are object creation domain.
The important thing is Memory creating structure.
Shape sh = new Shape();
Circle cir = new Circle();
In the graphic below, Shape is class type, sh is reference, latter Shape means created object(Shape() property).
When Shape(parent) is created, only Shape object is created. When Circle(child) is created, Circle(child) and Shape(parent) is both created.
4 major features of memory
- when child is created, parent is created too.
- when child's blueprint is created, parent's blueprint is created too
- parent's address is referenced. the area which "sh" refers, refers "shape" object.
- Only method that's declared in static memory can be called. sh cannot see Heap.
understanding 4 major features of memory
Heap area is invisible and only can be called by method which is declared in static(blueprint). the method which is not in static area cannot use it.
parent is created too when child is created. When you create circle in Circle type, you can use method of both Shape and Circle which is related in inherit.
Shape sh1 = new Circle();
Circle sh2 = (Circle)sh1; // Circle sh2 = sh1 as Circle;
child object can be created by parent's type which is related to polymorphism. The thing is memory structure.
'C#' 카테고리의 다른 글
System.IO - FileStream (0) 2019.06.11 delegate (0) 2019.06.10 C# polymorphism (2/4) - Override (0) 2019.06.06 Indexer (0) 2019.06.06 C# polymorphism (1/4) - Overloading (0) 2019.06.05