When working with arrays in C++, is there a simple way to access multiple indices of an array at once à la Python's :?
E.g. I have an array x of length 100. If I wanted the first 50 values of this array in Python I could write x[0:50]. In C++ is there an easier way to access this same portion of the array other than x[0,1,2,...,49]?
x[0], x[1], x[2]...for single elements. The way to access a portion of an array is via iteratorsstd::memcpywill be a good choice.std::array. (Andstd::vectoris another class to consider). I would recommend using those classes, and the answers here might be helpful. stackoverflow.com/questions/11102029/… If you wanted to modify the elements in question in the original array, you could consider making it an array of int references or pointers. Or just have the function doing the modifying takebeginandendparameters.