I have some Java code (constructor)
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_;
I would like to emulate a call within c++
RecursiveDescentParser *parser = new RecursiveDescentParser
(
stream,
false,
null,
null
);
If I use pointer arguments
std::string *str; std::ofstream *out
I can pass in nullptr but if I choose not to use pointer arguments, I can't pass null. What can I do to simulate passing null to a std::string and std::ofstream?
boost::optionalor make another mechanism to tell your function that the parameter is not passed.