Share via


Compiler Error C3809

'structure' : a managed type cannot have any friend functions/classes/interfaces

Managed types do not allow friends. To fix this error, do not declare friends inside managed types.

The following sample generates C3809:

// C3809a.cpp
// compile with: /clr
ref class A {};

ref class B
{
public:
   friend ref class A;   // C3809
};

int main()
{
}

The following sample generates C3809:

// C3809b.cpp
// compile with: /clr:oldSyntax
#using <mscorlib.dll>

__gc class A {};

__gc class B
{
public:
   friend __gc class A;   // C3809
};

int main()
{
}