2013-03-09 66 views
0

我正在使用C#和C++的遊戲。模型類用C#編寫,而層次結構存儲在XML文件中。當我想用C++讀取它並且想要構建項目時,我有這個奇怪的錯誤,而且我不會在哪裏找到一些錯誤。託管和非託管代碼錯誤C3699

Error 1 error C3699: '*' : cannot use this indirection on type 'Cadet::XMLReader::Models::Obstacle' C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\xmemory0 527 1 Cadet.Game 

這樣的錯誤是在xmemory0list文件?它們是什麼?它只發生在障礙課上,其餘都很好。

這是代碼

void SetupObstacles(std::list<Cadet::Game::Entities::Obstacle> &obstacles) 
    { 
    int size = CurrentLevel->Obstacles->Length; 
    Cadet::XMLReader::Models::Obstacle^ currentObstacle; 
    } 
+2

顯示你的代碼.. – 2013-03-09 18:09:23

+0

,因爲這些錯誤顯示xmemory0哪一部分並列出文件不在項目的一些文件 – 2013-03-09 18:11:41

+0

嘗試通過評論xmemory0建設,以便我們可以知道問題的根源 – nsconnector 2013-03-09 18:14:01

回答

0

的一部分,你有一個指向Obstacle地方?

help on this error表明某些類型(例如平凡的屬性)不能有引用類型 - 你不能有指向它的指針。請嘗試使用^代替。

2

看起來像Cadet::Game::Entities::Obstacle是一個託管類(因爲您聲明currentObstacle作爲^的參考)。如果是這樣的話,你不能直接在STL容器中存儲管理對象,如std::list<>

很難說下一個W/O更方面做什麼,但一個可能的解決將是改變你的SetupObstacles方法:

void SetupObstacles(System::Collections::Generic::List<Cadet::Game::Entities::Obstacle>^ obstacles) 
    { ... }