stlmap - Does map<key, data> in C++ STL support native data types like Structures? -
i trying write this. question how map key native data type structure. wrote snipped couldn't compile it. have ideas on how achieve thing?
#include <map> #include <iostream> typedef struct _list { int a,b; }list; map<int,list> test_map; int main(void) { cout <<"testing"<< endl; return 0; }
a number of problems here:
you're missing either
using::std
orstd::map
, compiler doesn't knowmap<int,list>
means.assuming have
using namespace std
declaration, typedeflist
might collide stl collection of same name. change name.your
typedef struct _tag {...} tag;
construct archaic holdover 80's. not necesarry, , frankly rather silly. gets nothing.
here's code fixed:
#include <map> #include <iostream> struct mylist { int a,b; }; std::map<int,mylist> test_map; int main(void) { std::cout <<"testing"<< std::endl; return 0; }
Comments
Post a Comment