• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

how do you create a vector of structs?

dowxp

Diamond Member
struct account {
...
};

struct sharedmemory {
vector<account> accounts;
};

this gives an error for some reason 🙁


main.cpp: In function 'int main(int, char**)':
main.cpp:40: error: 'main(int, char**)::account' uses local type 'main(int, char**)::account'
main.cpp:40: error: trying to instantiate 'template<class _Alloc> class std::allocator'
main.cpp:40: error: template argument 2 is invalid
 
no, you have to put the struct in a seperate file. gcc doesn't accept local variables as templates.

- dow
 
Originally posted by: dowxp
no, you have to put the struct in a seperate file. gcc doesn't accept local variables as templates.

- dow
What do you mean "local variables"? I know almost nothing about c++ but the general idea of a parametrized container is that you do it with a type, not a variable. Your declaration of "struct account" was a type, not a variable, so far as I understand what you posted.
 
Back
Top