Do I always have to specify absolute path for objects instantiated from std::fstream
class? In other words, is there a way to specify just relative path to them
You can use relative paths. They're treated the same as relative paths for any other file operations, like fopen
; there's nothing special about fstream
in that regard.
Exactly how they're treated is implementation-defined; they'll usually be interpretted relative to your process's current working directory, which is not necessarily the same as the directory your program's executable file lives in. Some operating systems might also provide a single working directory shared by all threads, so you might get unexpected results if a thread changes the working directory at the same time another thread tries to use a relative path.