CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Hybrid View

  1. #1
    Join Date
    Sep 2011
    Posts
    3

    How to Make an array of objects in visual c++ 2010

    I need to create an array of objects to hold labels in visual c++ 2010,
    i tried:

    Object^ *labelArray;
    labelArray=new Object^ [15];

    but this error came up:
    error C2728: 'System::Object ^' : a native array cannot contain this managed type
    Did you mean 'array<System::Object ^>'?

    So how to make this array and what does it mean by array<System::Object ^>

    Thanks

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: How to Make an array of objects in visual c++ 2010

    Quote Originally Posted by desoky725 View Post
    I need to create an array of objects to hold labels in visual c++ 2010,
    i tried:

    Object^ *labelArray;
    labelArray=new Object^ [15];
    Wrong forum.

    That code is Managed C++, not traditional C++. There is a managed C++ forum, and you should post your question there.

    Regards,

    Paul McKenzie

  3. #3
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,234

    Re: How to Make an array of objects in visual c++ 2010

    [ Moved thread ]
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  4. #4
    Join Date
    Aug 2009
    Location
    Finally back in Alaska
    Posts
    141

    Re: How to Make an array of objects in visual c++ 2010

    array<System::Windows::Forms::Label^,1>^ thelabels=gcnew array<System::Windows::Forms::Label^,1>(5);

    creates an array of 5 labels.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured