For legacy reasons, iostreams in C++03 expects a C-style, null-terminated string as argument and doesn't understand std::string
. Fortunately, std::string
can produce a C-style, null-terminated string, with the function std::string::c_str()
:
modelStream.open(STRING.c_str(), ios::in);
This was actually "fixed" in C++11, so if you were using it your original code would be functional.
Also, an all-caps variable name is not recommended; neither is a variable called "string". Make the name describe the meaning.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…