-
vector of ints[]
hey every1,
i'm tryin to declare a vector of ints[]
i'm preparing strings of numbers each of 32 digits, each digit means somethin different so i need to access them individually.
Well VC++ doesn't like
Code:
vector <int[32]> myInts(4);
gives me abuse like
Code:
: error C2440: 'type cast' : cannot convert from 'int' to 'int [32]'
any1 got any ideas how i can get this together?
Cheers,
Rob.
-
The problem is that you are using an array to instantiate the object. Try using vector<int*> instead and just allocate a new int[32] for each item you wish to add (remembering of course to deallocate later).
-
Or, if you don't want to use dynamic allocation, you can use a vector of vectors:
Code:
vector<vector<int> > myInts(4, vector<int>(32, 0));
That will create a vector of four vectors each with 32 ints initalized to 0.