'Recursive Include with no cpp and no forward decalaration
I have two files one calling the other with hpp guards that I am not including. I get an error saying :
provider.hpp: error C2653: 'data': is not a class or namespace name
This is because of the declaration, I believe:
static std::string provider::get(const data::details& details)
The following code:
// provider.hpp
#include <data.hpp>
class provider
{
public:
static std::string get(const data::details& details)
{
static provider me;
return me.private_get(details);
};
std::string private_get(const data::details& details) const
{
return "this is data";
};
};
and I have something like this in another file:
// data.hpp
#include <provider.hpp>
class data
{
public:
class details
{
//bla bla
std::string m_name;
};
public:
data(const data::details& details)
{
m_data = provider::get(details);
};
private:
std::string m_data;
};
You can see that one file uses the other. Please could you help me solve this problem under the following restriction please:
- I don't want to add any files (unless there is no solution you can think off).
- I don't want to use the cpp (unless there is no solution you can think off).
- I want to keep the design as it is (unless there is no solution you can think off).
Forward declaration wouldn't work because I am not only using the type.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
