c++ - how to create a vector as an argument -


i have object takes vector 1 of it's constructor arguments. have around 1000 of these objects (contained in vector) in each of 12 files time i'm finished, , i've been experimenting layout. best way can find work create arguments within object definition.

here basic version of struct:

struct myobject {   myobject (vector<int>);   vector<int> paralist; } 

so object definition this:

myobject object1 ( {0, 1, 2} ); myobject object2 ( {0, 3, 1} ); myobject object3 ( {5, 7, 5, 6} ); myobject object4 ( {4} ); 

this works, i'd construct objects within vector definitions instead. so:

vector<myobject> objectlist {   ( {0, 1, 2} ),    ( {0, 3, 1} ),   ( {5, 7, 5, 6} ),   ( {4} )   }; 

it feels should work, doesn't. get:

error: expected primary-expression before '{' token error: expected ')' before '{' token error: expected '}' before ')' token 

i feel syntax correct if possible, i'm trying not possible?

edit:

sorry, besides few spelling mistakes i'm not sure why off topic. i've been reading through rules , i'm still not sure, please comment or pm me i've done wrong can avoid in future? that's not meant moany, want make sure right.

you should this:

std::vector<myobject> objectlist {{{0, 1, 2}} , {{0, 3, 1}} , {{5, 7, 5, 6}} ,{{4}}}; 

live demo


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

c - Unrecognised emulation mode: elf_i386 on MinGW32 -