Reminder : memory is divided in two main section heap and stack
- Heap for dynamic memory allocation - stack for static memory allocation
array vs vector in memory ?
we take this example
#include
#include ... auto myArray =array<int,4>{1,2,3,4} ;
auto myVector =vector{1,2,3,4} ; // Display the adress of myArray and myVector std::cout<<"adress of myArray " <<&myArray<<std::endl; std::cout<<"adress of myVector" <<&myVector<<std::endl ;
// display the adress the first adress of myArray and myVector std::cout<<"adress of myArray[0] " <<&myArray[0]<<std::endl; std::cout<<"adress of myVector[0]" <<&myVector[0]<<std::endl ;
Result :
adress of myArray 0055FBBC adress of myVector0055FBA4 adress of myArray[0] 0055FBBC adress of myVector[0]00980C60
===> This show that c++ handle Vectors and array in a different way the adress of myArray is the same as the adress of the first element :the array is directly located where the data is stored (stack)
the adress of myVector is not the same as the adress of the first element: the vector actualy is a pointer (located in the stack) assocaited to data located in the heap









Auto comment: topic has been updated by marouenkd_999 (previous revision, new revision, compare).
At least I know it's not GPT...
My blog post is based on my own knowledge, which includes concepts from structured learning like Data-Oriented Scientific Programming (Coursera, Module 1). If you’d actually read it, you’d see the depth isn’t something ChatGPT can replicate. I’m happy to explain any part of my logic—but baseless claims just waste everyone’s time