Jump to content
  • Advertisement
Sign in to follow this  
Ataru

.net noob

This topic is 5023 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know c++ very well, but I've just recently been getting into .net (with no book right now) and got stuck doing a simple thing. I just want to create a type, and the create a managed aray of that type. I define the type as so:
	__gc public struct memorizedObject
	{
		System::String *s_question;
		System::String *s_answer;
		Double d_weight;

		static bool op_greater(memorizedObject &_u, memorizedObject &_v)
        {
			return _u.d_weight < _v.d_weight;
        }

	};


Now this line fails: memorizedObject* mo_objectList = new memorizedObject[lineCount]; I get this error "error C2691: 'memorizer::memorizedObject' : invalid type for __gc array element:" Why? Is there some special way I have to declare my data type to be able to create an array?

Share this post


Link to post
Share on other sites
Advertisement
I still get errors

error C3149: 'memorizer::memorizedObject' : illegal use of managed type 'memorizer::memorizedObject'; did you forget a '*'?

and

error C2691: 'memorizer::memorizedObject' : invalid type for __gc array element

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Ahh, I don't really use managed C++ but I just found in MSDN that that only works for value types. This works though (well, it did for me anyway):
memorizedObject *mo_objectList[] = new memorizedObject*[100];

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!