You don't create objects using new
in C++ unless you want dynamic allocation. new
returns a pointer. This should work.
std::string f("main.js");
std::ifstream ifs(f.c_str());
The constructor of std::ifstream
expects a const char *
so you need to use std::string::c_str()