【发布时间】:2021-04-11 21:37:04
【问题描述】:
我有两个头文件,animation.h 和 hero.h,
这是animation.h的代码:
#include <SFML/Graphics.hpp>
#include <iostream>
#include "hero.h"
#ifndef ANIMATION
#define ANIMATION
//Class
#endif
对于hero.h:
#include <SFML/Graphics.hpp>
#include <iostream>
#include "animation.h"
#ifndef HERO
#define HERO
//Class
#endif
即使使用包含防护,我也会收到错误消息 #include file "" includes itself。
我不熟悉使用包含守卫等,所以这可能是一个非常微不足道的错误。
感谢您的帮助
【问题讨论】:
-
为什么动画中会包含英雄?我认为英雄需要动画,但动画不知道英雄或任何其他动画实体。所以你应该在需要它的 cpp 文件中包含 hero,而不是动画(如 hero.cpp)
标签: c++ include include-guards