I want to create a vector of trains, where each train needs a vector of pairs.
If I run the code outside of main(), I get these errors:
naive-bayes.cpp:17:15: error: template argument 1 is invalid
vector<pair> pairs;
naive-bayes.cpp:17:15: error: template argument 2 is invalid
Inside main(), I get these errors:
naive-bayes.cpp:22:15: error: template argument for 'template<class>
class std::allocator' uses local type 'main()::pair'
vector<pair> pairs;
naive-bayes.cpp:22:15: error: trying to instantiate 'template<class> class std::allocator'
naive-bayes.cpp:22:15: error: template argument 2 is invalid
Here is the code:
struct pair {
int index;
int value;
};
struct trains {
string label;
vector<pair> pairs;
};
#include <vector>? And are youusing namespace std?using namespace std, you are asking for trouble if you ever#include <utility>since there is a templatedstd::pair. Even worse, with some implementations, some standard header files include each other even when the standard doesn't require it.