managed c++ class library question

E

Elephant

Hello, quesion,

in a managed c++ class library I create a namespace ( MyNS ).
In namespace a struct ( MyStruct) and a class ( MyClass ).

public __value struct MyStruct{...};
public __gc class MyClass{...};

I get 2 errors that I don't understand:

In MyClass I make a member variable, which is a pointer to MyStruct:
MyNS::MyStruct* TestStruct;
but I get the following error: "cannot declare interior __gc pointer or
reference as a member of MyNS::MyClass".
What does this mean?

Also, I can't create memory with this pointer in a member function of the
class. Says it can't convert from __gc[] to __gc*.
Why not? I can do this with other types.

Any help appriciated.
 
T

Tomas Restrepo \(MVP\)

Hello, quesion,
in a managed c++ class library I create a namespace ( MyNS ).
In namespace a struct ( MyStruct) and a class ( MyClass ).

public __value struct MyStruct{...};
public __gc class MyClass{...};

I get 2 errors that I don't understand:

In MyClass I make a member variable, which is a pointer to MyStruct:
MyNS::MyStruct* TestStruct;
but I get the following error: "cannot declare interior __gc pointer or
reference as a member of MyNS::MyClass".

the struct is a value type. Makes no sense to keep a pointer to it from the
__gc class. Instead, store the value:

MyNS::MyStruct TestStruct.
 

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