vector problems

Hello!
I'm trying to use vector class in VS 2005 Express.

I have #include <vector> and using namespace std; and i still need to do this:
std::vector<int> vek;
Like this works fine.
Why do I std is needed again Using namespace std should be enough. All is in *.h header file.

And more important problem. I need to have a lots of 0-1 data(milions, up to 10). I decided to use bit_vector(http://www.sgi.com/tech/stl/bit_vector.html) instead of vector<bool> - size matters for me. It should be included in vector class but its not or I'm doing sth wrong. How to use it/link it/include it Maybe you can recommend other solution for that
Thanks in advance!




Answer this question

vector problems

  • peppereyes

    Well, it works fine now without std:: <- i can't explain it :)

    According to VS help:
    "Unlike the similar vector<bool> Class, the bitset class does not have iterators and is not an Standard Template Library container. It also differs from vector<bool> by being of some specific size that is fixed at compile time in accordance with the size specified by the template parameter N when the bitset<N> is declared."

    Bitset does not have iterators but I will propably use it to avoid using not oficial parts of C++ Standard.

    Thanks for help!


  • jenjen

    Could you show a fuller example The following works fine for me:

    #include <vector>

    using namespace std;

    int main()
    {
       vector<int> vint;
    }


    bit_vector is not an official part of the C++ Standard and hence is not part of the Visual C++ release. Would std::bitset work for you You'll find the definition in the bitset header file.

  • vector problems