带有混合代码的C ++ / CLI错误C3767

时间:2014-03-31 22:17:05

标签: dll c++-cli

我遇到错误C3767的问题。使用VS2010和我有一个类似于下面简化的代码。我有两个类c ++ / cli。类A是混合类,类B实例化类A的对象。当类B尝试读取类的非托管成员的值时,我得到错误C3767。我不能包含A类的标题,但只能引用dll。我哪里错了?但更重要的是,我该如何解决? 感谢您的耐心和抱歉我的英语不好。

A类:

// Test_Prog_A.h

#pragma once

#include <vector>

using namespace System;
using namespace System::Collections::Generic;
using namespace std;

namespace Test_Prog_A {

    public ref class Class_A
    {

    public:

        Class_A()
        {
            unmVect = new vector<int>();
            m_A = gcnew List<int>();
        }

        ~Class_A()
        {
            this->!Class_A();
        }

        !Class_A()
        {
            delete unmVect;
        }

        void Init()
        {
            for(int i = 0;i < 10; i++)
            {
                unmVect->push_back(i + 10);
                m_A->Add(i + 30);
            }
        }

        property vector<int>* Vect
        {
            vector<int>* get()
            {
                return unmVect;
            }
        }

        property List<int> ^Lista
        {
            List<int> ^get()
            {
                return m_A;
            }
        }

    private:

        vector<int> *unmVect;
        List<int>   ^m_A;
    };
}

B组:

// Test_Prog_B.h

#pragma once

#include <vector>
//#include "Test_Prog_A.h"      <---------- i must not use this include :/ i can use only "Test_Prog_A.dll"

using namespace System;
using namespace System::Collections::Generic;
using namespace std;
using namespace Test_Prog_A;

namespace Test_Prog_B {
    public ref class Class_B
    {
    public:
        Class_B()
        {
            m_Class_A = gcnew Class_A();
            mngList1 = gcnew List<int>();
            mngList2 = gcnew List<int>();
        }

        ~Class_B()
        {
            this->!Class_B();
        }

        !Class_B()
        {
            delete m_Class_A;
        }

        void DoNothing()
        {
            m_Class_A->Init();
            for each(int i in *m_Class_A->Lista)
            {
                mngList1->Add(i)
            }

            for each(int i in *m_Class_A->Vect) <==== C3767
            {
                mngList2->Add(i);
            }
        }

    private:

        Class_A     ^m_Class_A;
        List<int>   ^mngList1;
        List<int>   ^mngList2;
    };
}

错误:

Errore  1   error C3767: 'Test_Prog_A::Class_A::Vect::get': funzione o funzioni candidate non accessibili   e:\visual studio 2010\projects\test_prog_b\test_prog_b\Test_Prog_B.h    42  1   Test_Prog_B

Errore  2   error C1903: impossibile recuperare l'errore o gli errori precedenti. Interruzione della compilazione   e:\visual studio 2010\projects\test_prog_b\test_prog_b\Test_Prog_B.h    42  1   Test_Prog_B

0 个答案:

没有答案