C#(2005) DLL using in VSC++(2005) - Needs copy constructor???

  • Thread starter Mas L via DotNetMonster.com
  • Start date
M

Mas L via DotNetMonster.com

Hi,

I have a C-sharp DLL(C#2005) and I use it as a reference in a VSC++(2005)
project.
When I

Myclass Obj = gcnew Myclass();

he says that I need a copy constructor!!??!!! Is there a way to avoid this?

Kind Regards
NETFAN
 
W

Willy Denoyette [MVP]

No, you need to create a reference variable when creating a heap allocated
object.
Myclass^ Obj = gcnew Myclass();
....
or:
MyClass Obj;
....
when creating a "stack allocated" one.

Willy.
 
N

Nicholas Paldino [.NET/C# MVP]

NETFAN,

If you want the object to be created on the stack, then you have to
remove the gcnew keyword. If you want to hold a reference to an object,
then you have to declare a reference, which I believe you do like so:

// Create a new instance of Myclass and get the reference.
Myclass^ Obj = gcnew Myclass();

Hope this helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top