Skip to content

In This Repo, we will discuss different topics about memory management in c++ like how the computer deals with executable programs and how it stores its data in memory, dealing with pointers and reference and heap, call stack

License

Notifications You must be signed in to change notification settings

MinaFaried3/Memory-Management-cpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Memory-Management-cpp-

cplusplus

In This Repo, we will discuss different topics about memory management in c++ like how the computer deals with executable programs and how it stores its data in memory, dealing with pointers and reference and heap, call stack

this repo contains lessons about memory management in cpp :

  • pointers and reference
  • stack and heap
  • how to avoid memory leak
  • 1d,2d array under the hood
  • advanced tips and tricks

example

    /*
      TODO : int arr[2][3] = {{1, 2, 3}, {4, 5, 6}};

      * - arr in last example:
          - is the pointer to the 2d array = arr
          - is pointer to first node(array) in 2d array = *arr = arr[0] = &arr[0]
          - is address to first element in first array = &arr[0][0]
          ? arr = *arr = arr[0]  = &arr[0] = &arr[0][0]

     * - arr+1 in last example:
          - is pointer to second node(array) in 2d array = arr+1 = arr[1] = &ptr1[1]
          - is address to first element in first array = &arr[1][0]= *(arr+1)
          ? arr+1 = arr[1] = &arr[1] = &arr[1][0] = *(arr+1)

      * - (**arr) in last example:
          - is the value of the first element in first array = **arr = arr[0][0]
          ? **arr = arr[0][0] = *arr[0] = *(*arr+0)

      * - *(*arr+1) in last example:
          - is the value of the second element in first array = *(*arr+1) = arr[0][1]
          ? *(*arr+1) = arr[0][1]


      * - **(arr+1) in last example:
          - is the value of the first element in second array = **(arr+1) = arr[1][0]
          ? **(arr+1) = arr[1][0] = *arr[1]


      * - *(arr+1)+2 in last example:
          -  is address of last element in  second array = *(arr + 1) + 2 = &arr[1][2]
          ? *(arr + 1) + 2 = &arr[1][2]

      ! notice that:
          - when increase arr + 1 this jump to second node(array) in the 2d array
          - when increase *arr + 1 this jump to second element in the 1d array


  */


Connect with me:

click the icon to contact 👆 :

mina_eldihabi mina_eldihabi minafaried mina.f.eldihabi mino_f.eldihabi

About

In This Repo, we will discuss different topics about memory management in c++ like how the computer deals with executable programs and how it stores its data in memory, dealing with pointers and reference and heap, call stack

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages