【发布时间】:2021-04-06 23:44:28
【问题描述】:
我有一个类,我想要一个使用 nlohmann::json& 作为参数的函数:
class MyClass
{
public:
void foo(nlohmann::json& node);
};
但我不想在我的标题中包含 json.hpp 文件,只是我的 .cpp。如何在标题中声明 nlohmann::json?我试过了:
namespace nlohmann
{
class json;
}
但这似乎不起作用。
【问题讨论】:
-
您能否详细说明“似乎不起作用”?它会产生编译器错误吗?链接器错误?函数中的行为不正确?
-
怎么不行?你看到了什么错误?
标签: c++ forward-declaration nlohmann-json