So I\'m having some type problems in my c++ program. Here is the code:
#include \"NHSFileparser.h\"
#include \"NHSFileController.h\"
#include
#inc
You cannot put statements outside functions, only declarations and definitions. Put your code inside main
.
directories.push_back(directory1);
Code statements like that can only go inside functions.
In C++11, you can initialise the vector in its declaration:
std::vector<std::string> directories {"...", "..."};
If you're stuck in the past, then you could move the push_back
statements inside main
, or use something like the Boost.Assignment library, or write a function to return a populated vector:
std::vector<std::string> make_directories() {
std::vector<std::string> directories;
directories.push_back("...");
directories.push_back("...");
return directories;
}
std::vector<std::string> directories = make_directories();