what are some of the examples of the static and dynamic arrays

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lillianmutinda
    New Member
    • Mar 2018
    • 1

    what are some of the examples of the static and dynamic arrays

    I am confused on the difference between static and dynamic arrays,in the examples part
  • weaknessforcats
    Recognized Expert Expert
    • Mar 2007
    • 9214

    #2
    There is no difference in how they work.

    Static arrays are allocated at compile time by the compiler.

    Dynamic arrays are allocated at run time by you using a memory allocation function.

    Read this:

    Comment

    • sweta9
      New Member
      • Mar 2018
      • 1

      #3
      Static array haS fixed length.length is defined while initialization.
      eg:int x[10];

      they have reference address i.e index number.

      Dynamic array does not have the fixed length. Yo can add or delete the element .
      e.g int* y=new int[10];
      delete[] y;
      * is dereference .They are store in heap. "New" keyword have dynamix storage duration.

      Comment

      • weaknessforcats
        Recognized Expert Expert
        • Mar 2007
        • 9214

        #4
        The static array has fixed length because the compiler creates it at compile time.

        The dynamic array has a length you decide because it is created at run time.

        In both cases you cannot delete an array element. If the array is dynamic you can delete the array because you created it. If the compiler created the array, then only the compiler can delete it.

        Did you read the "Arrays Revealed" link I sent you last time?

        Comment

        Working...