|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > .NET Development > How to make arrays of class objects? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|