// native.h
class NativeClass
{
#ifdef __cplusplus_cli
    friend ref class ManagedClass;
#endif

private:
    int PrivateMethod();
};

// managed.h
ref class ManagedClass
{
private:
    int PrivateMethod()
    {
        return m_NativeObj->PrivateMethod();
    }

    NativeClass* m_NativeObj;
}

핵심은 __cplusplus_cli 키워드다. 이 키워드가 없어도 되지 않냐? 이렇게 생각하기 쉬운데 그렇지 않다. 네이티브 컴파일러는 ref 키워드를 모른다. 그래서 네이티브 컴파일러가 이 헤더 파일을 참조할 때 반드시 __cplusplus_cli 키워드가 있어야 한다. 그렇지 않으면 컴파일 오류가 난다.