<vectors> vs. arrays

Hi: Thanks for taking time to read my question. I am trying to integrate a C++ code into another compiler that will not allow vectors. I had the programmer change the code to arrays and used a const int MAX_SIZE = 1000;.

My understanding is that vectors are sort of a dynamic array allowing the size to grow and shrink according to need, and that no size is initialized like the array.

Can anyone provide some insight as to the advantage or disadvantage of using this method and any problems I may face.

Thank you Again!
Last edited on
Advantage: It will compile in C, or whatever that compiler you're talking about is.
Disadvantage: Arrays are limited by size. Once you've filled them, you'll have to do some manual memory management if you want to keep adding data to it.
if you compare arrays with vector.. you may not find any advantages of array.
vectors are generic (you can use int, char or any data type you can think of), they can increase or decrease in size, they are dynamic, allocate memory from heap and not from programs stack memory.. no need to do memory management.. they will release unused memory as compared to array which will occupy the allocated memory till the program is running.. what else you need.

arrays dont have anything of these.. but they may be faster at times... as they dont allocate or deallocate memory.. ;)
you may face lots of problems if you are thinking to remove vectors from your code...dont get demotivated though...
Topic archived. No new replies allowed.