How to Make an array of objects in visual c++ 2010
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

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

  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,423

    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
    ovidiucucu's Avatar
    ovidiucucu is offline Moderator/Reviewer Power Poster
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,021

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

    [ Moved thread ]
    Ovidiu Cucu
    "When in Rome, do as Romans do."
    Visit: Microsoft Virtual Academy
    Follow: https://twitter.com/#!/ovidiucucu
    My blog: http://codexpert.ro/blog/author/ovidiu-cucu/

  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
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center