.NET Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgramming.NET Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old October 13th, 2005, 01:49 PM
kolokol kolokol is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Aug 2005
Posts: 18 kolokol User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 3 m 5 sec
Reputation Power: 0
How to make arrays of class objects?

I have looked for the answer to this for a while now and i still can't figure it out. This whole managed code business is confusing.
You can see my attempt at this in my previous post. However the code ive written there is just plain wrong.
What i want is a class that stores a string, and an array of objects of that class.
I assume that i would use the default constructor and use a member function to pass data to the objects. My incorrect attempt at these three things is below, please can someone correct it and for extra bonus points explain why you do it like that.

__gc class AminoAcids
{
public:
//default constructor
//getdata function because i cant use array if i have non default
//constructor, i.e. one with arguments
void getData(System::String __gc *pLetter, System::String __gc *pName, System::String __gc *pHp)
{
//use the function to copy values into the object
letter = pLetter;
name = pName;
hp = pHp;
}

I tried to use the following to create an array of AminoAcids objects.
AminoAcids *array[] = __gc new AminoAcids*[21];
To pass data to the objects i tried to use.
array[i]->getData(x , y , z);

I suspect the above code is plain wrong but it shows what im trying to do. I don't understand all these __gc's floating about
and im completely lost as to how to do it properly.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgramming.NET Development > How to make arrays of class objects?


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT