Represents a segment of the one-dimensional array. Objects of this class should only be allocated using System::MakeObject() function. Never create instance of this type on stack or using operator new, as it will result in runtime errors and/or assertion faults. Always wrap this class into System::SmartPtr pointer and use this pointer to pass it to functions as argument.
#include<system/array_segment.h>#include<system/smart_ptr.h>usingnamespaceSystem;voidPrint(constSmartPtr<ArraySegment<String>>&segment){for(autoi=segment->get_Offset();i<segment->get_Offset()+segment->get_Count();i++){std::cout<<segment->get_Array()[i]<<' ';}std::cout<<std::endl;}intmain(){// Create and fill the array.
autoarray=System::MakeObject<Array<String>>(3);array[0]=u"First";array[1]=u"Second";array[2]=u"Third";// Create the array segment that contains the entire array.
autofullArray=MakeObject<ArraySegment<String>>(array);// Print the array segment items.
Print(fullArray);// Create the array segment.
autosegment=MakeObject<ArraySegment<String>>(array,1,2);// Print the array segment items.
Print(segment);return0;}/*
This code example produces the following output:
First Second Third
Second Third
*/