I have two files, gui.hpp
and util.hpp
. The source code is in respective .cpp
files
gui.hpp
#pragma once
#include "util.hpp"
class Text_; //forward-declaration
typedef Text_* TextPtr;
//Things that use Text_ and TextPtr
class Text_{
//uses stuff from util.hpp
};
util.hpp
#pragma once
#include "gui.hpp"
std::vector<TextPtr> vec;
Unfortunately, this does not compile. They create random unrelated errors, so it's not worth posting them here. But, it all stems from each file depending on the other.
I can fix this by defining util.hpp as
#include "gui.hpp"
class Text_; //Forward-declare
std::vector<Text_*> vec;
Why do I need to forward-declare Text_
again when gui.hpp
is already included?
How can I let util.hpp
use TextPtr
instead of Text_*