Hi,
ich arbeite noch nicht so lange mit SmartPointern, und hab ein Problem:
Hier erstmal der Code:
|
C-/C++-Quelltext
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
std::unique_ptr<Engine> MyEngine;
std::shared_ptr<Game::GameInstance> GameInstance;
[...]
void init(HWND hwnd)
{
MyEngine= std::unique_ptr<Engine>();
GameInstance = MyEngine->CreateGameInstance();
try
{
GameInstance->CreateDeviceContext(hwnd, (float)winWidth, (float)winHeight, false);
}
catch (STEngine::Exceptions::STException& e)
{
MessageBox(hwnd, (WCHAR*)e.GetError().c_str(), L"FEHLER",0);
}
}
|
//Methode CreateGameInstance() der Engine
|
C-/C++-Quelltext
|
1
2
3
4
|
std::shared_ptr<Game::GameInstance> Engine::CreateGameInstance()
{
return std::shared_ptr<Game::GameInstance>(new Game::GameInstance(this));
}
|
//GameInstance - Konstruktor
|
C-/C++-Quelltext
|
1
2
3
4
|
Game::GameInstance::GameInstance(Engine* engine)
{
this->Engine = engine;
}
|
Wenn ich dieses Beispiel Compiliere, bekomme ich beim Starten in der Zeile
|
C-/C++-Quelltext
|
1
2
3
4
|
try
{
GameInstance->CreateDeviceContext(hwnd, (float)winWidth, (float)winHeight, false);
}
|
eine Exception in der memory-Include Datei.
Genauer kann ich den Fehler nicht beschreiben.
Was mach ich hier falsch?
Gruß