Value Class Reference



Hello,

How can I store the pointer to a value class in managed C++ similar to
this:

// Old unmanaged C++ code:
struct MyStruct
{
// some members
};
class MyClass
{
private:
MyStruct* m_pMyStruct;
public:
MyClass(void)
{
m_pMyStruct = new MyStruct();
}

MyStruct* GetMyStruct() { return m_pMyStruct; }
};

I tried using MyStruct^ _MyStruct = gcnew MyStruct(), but the
application on the C# side recognizes the returned value as ValueType
which is meaningless.

Thanks.

.



Relevant Pages

  • Re: Redeclaration error when forward declaraing a structure
    ... interface between c and c++ files). ... To avoid compiler error, i forward declared the structure as in ex. ... struct MyStruct; ... class MyClass ...
    (microsoft.public.vc.language)
  • Re: Translate from C to VB
    ... Private Declare Function myFunc Lib "some" As Long ... Dim result As MY_STRUCT ... > typedef struct _MYSTRUCT { ... > Private Sub Command1_Click ...
    (microsoft.public.vb.winapi)
  • Re: pass data structure pointer to c++ class method
    ... I have the activex compiled using stdcall with 1 byte struct alignment. ... int msA; ... Private Declare Function TestStruct Lib "X:\Path\File.dll" (ByRef inStruct As MyStruct) As Long ... Private Type MyStruct ...
    (microsoft.public.vb.general.discussion)
  • Translate from C to VB
    ... typedef struct _MYSTRUCT { ... const char* p1; ... Private Type MY_STRUCT ...
    (microsoft.public.vb.winapi)
  • Structure (Newbie)
    ... Assume that we have a structure called myStruct: ... What is the the difference of referencing the members like this: ... is it that foo is a member-variable, and bar is a member-variable which is a ...
    (comp.lang.c)

Loading