VC++ 2005 Express Edition & an array of type Point

I am using VC++ 2005 Express Edition & I am having difficulty with creating an array of Point. I have tried

Point *a = new Point[50];

Point *a[] = new Point[50];

Point ^a = gcnew Point[50];

array<Point ^> ^a = gcnew array<Point ^>(50);

Point a[50];

& variants of these. Some of them compile & some do not. However, none of them work by allowing me to access their X & Y values (the program sometimes compiles but then crashes when run). The simple:

Point a = new Point; works properly.

I try to access the member variables with

aIdea->X or aIdea->X::set (or get) or aIdea.X

& if the program compiles this is where it crashes.

Can anyone help me I cannot use DrawPolygon (& other drawing functions) without a Point array.



Answer this question

VC++ 2005 Express Edition & an array of type Point

  • hobscrk777

    nobugz: Thank you for the reply - everything works fine now.
  • Blade68

    Point is a managed class so you definitely need gcnew to create the array. You're close but write it like this:
    array<Point>^ a = gcnew array<Point>(50);
    a[0].X = 1;

    array<Point^>^ declares an array of pointers to Point. Your program crashes because the pointers are still null.




  • VC++ 2005 Express Edition & an array of type Point