c++11 - c++ <vector> does not name a type -


so i'm having type problems in c++ program. here code:

#include "nhsfileparser.h" #include "nhsfilecontroller.h" #include <string> #include <vector>         std::string databasepath = "/media/sf_documents/skola/mvk/testdb/"; std::string dblang = "english"; std::vector<std::string> directories; std::string directory1 = "/media/sf_documents/skola/mvk/testdata/"; std::string directory2 = "/media/sf_documents/skola/mvk/testdata2/"; directories.push_back(directory1); directories.push_back(directory2); std::vector<std::string> queryterms; std::vector<std::string> return_files;  int main() { nhsfilecontroller fc(directory1, databasepath); bool b = fc.adddirectory(directory1); nhsdatabase database(databasepath, dblang); split( queryterms, "test", boost::is_any_of("_")); //split on lots of chars std::cout << "queryterms set." << std::endl; database.query(queryterms, return_files); std::cout << return_files.size() << std::endl; if (return_files.size() > 0){     std::cout << "file found: " << return_files[0] << std::endl; } return 0; } 

and when compile using g++ 4.6 , -std=c++0x on ubuntu 12.04 following error:

    error: ‘directories’ not name type 

on both lines trying push_back directories vector.

everything i've found far problems not declaring std::vector properly, (to extent of knowledge) have done.

you cannot put statements outside functions, declarations , definitions. put code inside main.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -