C++ header issue
So I essentially have the following code. I had working code and wanted to separate some of it into two different classes, D3DWindow
and D3DController
, rather than having it all in D3DWindow
. I don't believe it is a pch problem because it was working prior to the separation. The problem occurs in D3DController.cpp
. It says something along the lines of D3DController::Create(D3DWindow*) does not match type D3DController::Create(<error-type>*)
All of the files are in VS2010 and they are all contained in the same project. Nothing stood out immediately as the issue to me.
stdafx.h
#include <d3d10.h>
#include <windows.h>
#include "D3DWindow.h"
#include "D3DController.h"
stdafx.cpp
#include "stdafx.h"
D3DWindow.h
#include "D3DController.h"
class D3DWindow{
D3DController controller;
public bool init();
};
D3DWindow.cpp
#include "stdaf开发者_如何学编程x.h"
bool D3DWindow::init(){
if(!controller.create(this))
return false;
return true;
}
D3DController.h
#include "D3DWindow.h"
class D3DController{
public bool Create(D3DWindow* window);
};
D3DController.cpp
#include "stdafx.h"
bool D3DController::Create(D3DWindow* window){
// Do Stuff
return true;
}
You have a circular dependency. Perhaps you can use a class forward declaration instead of #include
. E.g.:
// #include "D3DWindow.h"
class D3DWindow; // forward declaration
class D3DController{
public bool Create(D3DWindow* window);
};
精彩评论