我是编程的新手,头文件的主题在我开始使用它们之后会让我失望.除此之外,我正在尝试使用预编译的头文件.我也在使用SFML库,所以我必须包含那些标题.
现在我有stdafx.h,main.cpp,然后是Ah,A.cpp,Bh,B.cpp,Ch,C.cpp,Dh和D.cpp中包含的类A,B,C和D.
如果包含所有文件中的标题,我将采用什么顺序?
stdafx.h中:
#include <SFML/Graphics.hpp>
#include <iostream>
Run Code Online (Sandbox Code Playgroud)
啊
#include "stdafx.h"
class A
{
//sfml class
};
Run Code Online (Sandbox Code Playgroud)
A.cpp
#include "stdafx.h"
#include "A.h"
Run Code Online (Sandbox Code Playgroud)
BH
#include "stdafx.h"
class B
{
//sfml class
};
Run Code Online (Sandbox Code Playgroud)
B.cpp
#include "stdafx.h"
#include "B.h"
Run Code Online (Sandbox Code Playgroud)
章
#include "B.h"
class C: public B
{
};
Run Code Online (Sandbox Code Playgroud)
C.cpp
#include "stdafx.h"
#include "C.h"
Run Code Online (Sandbox Code Playgroud)
DH
#include "A.h"
#include "C.h"
class D
{
A a;
C C; // if left uncommented I recieve a '1 unresolved externals' error
//sfml class
}
Run Code Online (Sandbox Code Playgroud)
D.cpp …