0

Pointers & arrays using indexs from for loop

I know it is possible to send an index i to a vector and get a value. Ex. vector[i] and it gives u the element you need. Is it possible to do this using a for loop that keeps looping and sends in indexs for arrays? Can the same thing happen for pointers? Please provide an example for me to try out.

28th Dec 2016, 8:59 AM
Kourosh Azizi
Kourosh Azizi - avatar
2 odpowiedzi
+ 1
The vector is a template class from C++ library to extending and simplification work with arrays. So, the array (without vector) uses indexes too too, but not supported other vector member functions int a[10]; for (int i=0;i<10l;i++) a[i]=2*i; int b=a[3]; Using with pointers can be simillar, or not. Because exist many ways how to organize more pointers (and object values alllocated in pointers). They can be organized as a array of pointers (you can use indexes), or list of pointers (where use iterators to cross between pointers) Looks for another container template classes in std library..
28th Dec 2016, 1:27 PM
Petr Hatina
Petr Hatina - avatar
0
This is helpful, thanks.
30th Dec 2016, 8:23 AM
Kourosh Azizi
Kourosh Azizi - avatar