Jump to content
  • Advertisement
Sign in to follow this  
Raeldor

Managed/Unmanaged Problem... Help!

This topic is 4262 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

Hi All, I am trying to wrap my C++ classes in Managed C++ so I can call them from C#, which works great for regular parameters (int, float), but when I define...
	public ref class Vector3
	{
	public:
		Vector3(float in_x, float in_y, float in_z) {x=in_x; y=in_y; z=in_z;}

		float x, y, z;
	};

	public ref class MCamera
	{
	private:
	public:
		MCamera(Vector3 in_source) {}
	};

and then try and call this from C# with...
            m_camera = new MCamera(new Vector3(0.0f, 0.0f, 0.0f));

I get the compile error... D:\Documents and Settings\rprice\My Documents\Visual Studio 2005\Projects\Terraformer4\Terraformer4\Form1.cs(40,24): error CS1501: No overload for method 'MCamera' takes '1' arguments The c++ assembly compiles find and the constructor looks good in the object browser for the assembly. Why is C# not recognizing this as having parameters? The following works fine in C# too...
            Vector3 test = new Vector3(0.0f, 0.0f, 0.0f);
            test.x = 1.0f;

I am really confused... help! Thanks Rael

Share this post


Link to post
Share on other sites
Advertisement
im not sure cause i havnt used managed c++ before but i think this

public ref class MCamera
{
private:
public:
MCamera(Vector3 in_source) {}
};

should be this

public ref class MCamera
{
private:
public:
MCamera(Vector3^ in_source) {}
};

so the compiler can distinguish passing a Vector3 (what ur code said) and a managed pointer to a Vector3 (what u do in the c# code).

Hope that helps

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!