Say I have a structure like this:
struct typeA
{
long first;
string second
double third;
};
If I announce
typeA myArray[100];
Then myArray is stored on the stack, consuming sizeof (typeA) * 100 bytes of garbage data (until I save some actual data, at least).
Whenever I pass this array as a parameter, I will always pass a pointer to the first of the first element on the stack. Thus, the pointer moves from stack to stack.
But if I declare
vector<int> myVector (4, 100);
Then the myVector object is actually stored on the stack and contains a pointer to the first element of the array of 4 * sizeof (int) bytes stored in the heap where the actual data is stored. Thus, the pointer jumps from the stack to the heap.
Whenever I pass this vector as a parameter, if I add it to the parameter list as follows:
vector<int> parameterVector
myVector .
:
vector<int> ¶meterVector
myVector, , , , myVector, , , .
?
:
- (, C, ) ?
- myVector ?
- , , , , , . ?
- , , ++ , , ? ( , ).
!