2014-01-05 78 views
1

我有這個類:C3767:候選人功能(S)沒有入店

#pragma once 

#ifndef _DEFINES_H_ 
#include "Defines.h" 
#endif 
#ifndef _GAMETIME_H_ 
#include "GameTime.h" 
#endif 
#ifndef _UTILITIES_H_ 
#include "Utilities.h" 
#endif 

#ifndef _GAME_H_ 

using namespace System; 

namespace BSGameFramework 
{ 
public ref class Game 
{ 
    public: 

     Game(); 
     virtual ~Game(); 

     void Run(HINSTANCE instance); 

     string Title; 
     int WindowWidth; 
     int WindowHeight; 

    protected: 

     virtual void Initialize(); 
     virtual void LoadContent(); 
     virtual void UnloadContent(); 
     virtual void Update(GameTime^ gameTime); 
     virtual void Draw(GameTime^ gameTime); 

    private: 

     HINSTANCE windowHandler; 
     HWND window; 
     DateTime lastTime; 
     TimeSpan totalGameTime; 

     D3D_DRIVER_TYPE driverType_; 
     D3D_FEATURE_LEVEL featureLevel_; 

     ID3D11Device* d3dDevice_; 
     ID3D11DeviceContext* d3dContext_; 
     IDXGISwapChain* swapChain_; 
     ID3D11RenderTargetView* backBufferTarget_; 

     void Shutdown(); 
}; 
} 

#define _GAME_H_ 

#endif 

,這是它的孩子:

#pragma once 

using namespace BSGameFramework; 

public ref class MyGame : Game 
{ 
public: 

    MyGame() 
    { 

    } 
}; 

然後當我主我打電話給我的運行功能:

#include <Windows.h> 
#include "MyGame.h" 

using namespace BSGameFramework; 

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) 
{ 
MyGame ^game = gcnew MyGame(); 

game->Run(hInstance); // Here the error 
} 

我得到這個錯誤:

Error 1 error C3767: 'BSGameFramework::Game::Run': candidate function(s) not accessible 
C:\Users\Nicola\Desktop\directx prove\BSGameFramework\FrameworkTestCpp\Main.cpp 10 1 FrameworkTestCpp 

我試圖從運行參數中刪除HINSTANCE,並且所有工作正常,但我需要它,所以有人可以解釋我爲什麼我得到這個錯誤,我該如何解決?提前致謝!

+1

可能重複[ C++ CLI錯誤C3767:候選函數不可訪問](http://stackoverflow.com/questions/947213/c-cli-error-c3767-candidate-functions-not-accessible) –

+0

我在檢查,我會告訴你,tnx:D – ThomasSquall

+0

關於你通過我的問題的解決方案,他們說問題是本機類型是私人默認情況下,CLI C++編譯器,使他們說使用#pragma make_public,對於誰做的問題是工作,但不適合我,現在我得到這個錯誤的傢伙: 錯誤錯誤C2158:「HINSTANCE」 :#pragma make_public指令當前僅支持本地非模板類型\t c:\ users \ nicola \ desktop \ directx證明\ bsgameframework \ bsgame \ Defines.h BSGame – ThomasSquall

回答

1

我已經解決了這種方式:

inline void Game::Run(IntPtr instance) 
{ 
windowHandler = (HINSTANCE)instance.ToPointer(); 


// other code 
} 

現在我傳遞一個IntPtr不是原生類型,等等主要功能我有這樣的:

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd) 
{ 
MyGame ^game = gcnew MyGame(); 

IntPtr instance(hInstance); 

game->Run(instance); 
} 
相關問題