我有一个依赖于"Blibrary"的图书馆"myLibrary".我希望"myLibrary"的用户不知道这种依赖.我试图隐瞒它没有运气,这是我现在所拥有的一个例子.
#include <game/Object.h>
#include <Blibrary/Component.hpp> // How can I remove this library header?
// forward declaring it? it's a template..
namespace myLibrary {
template<typename T>
struct Component: public Object, public Blibrary::Component<T>
{
};
//template<typename T>
//class Blibrary::Component<T>; //I Tried something like that..
//template<typename T>
//struct Component: public Object
//{
// Blibrary::Component<T> * m_impl;
//};
}
//I want the user do this when declaring a usermade component:
#include <game/Component.h> //<-- but without the Blibrary include dependency
class Position: public myLibrary::Component<Position>
{ …Run Code Online (Sandbox Code Playgroud)