automatic storage
- exists till the function ends.**
-> only useable in the scope
- automatic variable is variable used in function.
- allocated in stack
-> last-in, first-out
## example in automatic storage
int main()
{
char temp[42]; // this is automatic variable
return (0);
}
static storage
- exists till program ends.
- allocated in data
example in static storage
int main()
{
static char temp[42]; // this is static variable
return (0);
}
dynamic storage
- exits till
delete
is called.
-
new
and delete
operators manage memory poll (a.k.a free store)
- allocated in heap
- depend to programmer.
- WATCH MEMORY LEAKS
- recommend : locate
new
and delete
close.
example in dymaic storage
int main()
{
int *ptr = new int(42);
delete ptr;
return (0);
}
reference
Top comments (0)