Sign in to follow this  
Ataru

.net noob

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this