Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2005

Tip: Looking for answers? Try searching our database.

ArrayList class in Visual C++ .NET 2003

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
bor_kev - 26 Mar 2005 16:36 GMT
Hi,

I'm using Visual C++ .NET 2003 and I want to use the ArrayList class
in order to put managed classes in it.

For instance , i wrote :
(I created an empty .NET project)

#using namespace System::Collections;

__gc class point
{
 protected :
  int x; inty;

  public :
  point( int valx, int valy)
   {
      x=valx;
      y=valy;
     }

void getx{ return x;}
void gety {return y;}

// no destructor since it's a managed class

};

int main()
{
  point pt1(5,2);

 ArrayList * pal = new ArrayList(10);

 pal->Add(pt1);

return 0;
}

The compiler says that it cannot convert this point class into
Object*.
Then i tried to inherate point from the Object class...in vain.

I also tried pal->Add(__box(pt1));...in vain.

My question is : What should I do to store managed classes into the
ArrayList and work with them?

Sincerely

bor_kev
Posted at: http://www.groupsrv.com
Carl Daniel [VC++ MVP] - 26 Mar 2005 17:10 GMT
> Hi,
>
[quoted text clipped - 28 lines]
> {
>   point pt1(5,2);

point* pt1 = new point(5,2);

>  ArrayList * pal = new ArrayList(10);
>
>  pal->Add(pt1);
>
> return 0;
> }

-cd

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.