Some small misktakes in the code.. I have corrected them.. You are creating a new array with 4 elements but each element also needs to be initialized before using... no need to put public:ref use public ref instead
public ref class d
{
public:
int i;
};
Here I have crated a new object d for u[1] before using it..
array<d^> ^u = gcnew array<d^>(4);
u[1] = gcnew d;
u[1]->i = 9;
Hope this helps...