我有一些 Java 代码(构造函数)
RecursiveDescentParser
(
std::string inputStream,
bool fileService,
std::string filePathName,
std::ofstream writer
)
{
input_ = inputStream;
tokenizer_ = new Tokenizer(inputStream);
if (fileService == true){
error = new ErrorHandling(fileService, std::move(writer));
}
else{
error = new ErrorHandling(fileService, std::ofstream());
}
compiled_ = "";
}
Tokenizer *tokenizer_;
std::string input_, compiled_;
我想在 C++ 中模拟一个调用
RecursiveDescentParser *parser = new RecursiveDescentParser
(
stream,
false,
null,
null
);
如果我使用指针参数
std::string *str; std::ofstream *out
我可以传入nullptr,但如果我选择不使用指针参数,我就不能传递null。我可以做些什么来模拟将 null 传递给 std::string 和 std::ofstream?