422,172 Members | 2,196 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 422,172 IT Pros & Developers. It's quick & easy.

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

P: 1
I am confused on the difference between static and dynamic arrays,in the examples part
2 Weeks Ago #1
Share this Question
Share on Google+
3 Replies

Expert Mod 5K+
P: 9,093
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:
2 Weeks Ago #2

P: 1
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.
2 Weeks Ago #3

Expert Mod 5K+
P: 9,093
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?
2 Weeks Ago #4

Post your reply

Sign in to post your reply or Sign up for a free account.