2017-03-17 15 views
-1

自分のコードでmsclrを使用する必要がありますが、msclrも使用する別のクラス「ClassOne」を使用する必要があります。私は 'クラス'型の再定義エラーと基本クラスの未定義エラーを取得します。なぜこれが起こっているのか分かりません。2つの従属クラスでmsclr marshal_cppstdを使用する方法

両方のクラスが同じプロジェクトにあります。 #ClassOne.objを使用するとエラーが表示されます

どうすればこの問題を回避できますか?

ClassOne.h:

#ifndef _CLASSONE_H 
#define _CLASSONE_H 

ref class ClassOne 
{ 
public: 
    ClassOne(); 
}; 
#endif 

ClassOne.cpp:

#include "ClassOne.h" 
#include <msclr/marshal_cppstd.h> // For msclr::interop::marshal_as 

ClassOne::ClassOne() 
{ 
} 

ClassTwo.h:

#ifndef _CLASSTWO_H 
#define _CLASSTWO_H 
#using "ClassOne.obj" 

public ref class ClassTwo 
{ 
public: 
    ClassOne a; 
    ClassTwo(); 
}; 
#endif 

ClassTwo.cpp:

#include "ClassTwo.h" 
#include <msclr/marshal_cppstd.h> 

ClassTwo::ClassTwo() 
{ 
    msclr::interop::marshal_as<std::wstring>(L"text"); 
} 

エラー:

参照のスクリーンショット:Screenshot

答えて

0
#using "ClassOne.obj" 

私はこれが何であるか見当がつかない。以前はobjファイルでディレクティブを使うことはなかった。私は目的が何であるか分かりません。率直に言って、私はあなたがその#using行にエラーを表示していないことに驚いています。

あなたはClassTwoからClassOneを参照したい場合は、単に通常のC++のようなヘッダファイルが含まれます。

#using "ClassOne.h" 
関連する問題