Mega Code Archive

 
Categories / Visual C++ .NET / Collections
 

Create an interior pointer to elements of the array

#include "stdafx.h" using namespace System; ref class MyObject { }; int main() {    array<MyObject^>^ array_of_buf = gcnew array<MyObject^>(10);    for each (MyObject^ bref in array_of_buf)    {       bref = gcnew MyObject();    }    interior_ptr<MyObject^> ptr_buf;    for (ptr_buf = &array_of_buf[0]; ptr_buf <= &array_of_buf[9]; ptr_buf++)    {       MyObject^ buf = *ptr_buf;       // use the MyObject class    } }