vector of ints[]

This is a discussion on vector of ints[] within the C++ Programming forums, part of the General Programming Boards category; hey every1, i'm tryin to declare a vector of ints[] i'm preparing strings of numbers each of 32 digits, each ...

  1. #1
    Registered User
    Join Date
    Nov 2001
    Posts
    17

    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.

  2. #2
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    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).

  3. #3
    Registered User
    Join Date
    May 2003
    Posts
    161
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Maps with ints[]
    By robquigley in forum C++ Programming
    Replies: 4
    Last Post: 10-30-2003, 12:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21