Initialization of vectors in c++

Discussion in 'C++' started by pauldepstein@att.net, Apr 13, 2008.

  1. Guest

    Experimenting at home with visual c++, I see that int main()
    {std::vector<double> vect(5);} creates a vector whose 5 initial
    values are all 0. Is this standard or might the five initial values
    be different from 0? I'm a bit surprised by this as I would expect
    vect to consist of five uninitialized doubles. Why is it that double
    x; introduces a double which is uninitialized and yet the above vect
    is initialized? Or is this just a matter of the definition of the c++
    language which should just be accepted, and can't be derived from some
    other principle?

    Thank you,

    Paul Epstein
     
    , Apr 13, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Denis Remezov
    Replies:
    4
    Views:
    472
    Siemel Naran
    Apr 30, 2004
  2. Replies:
    3
    Views:
    702
    Shadowman
    Mar 26, 2008
  3. Replies:
    10
    Views:
    604
    Jerry Coffin
    Apr 17, 2008
  4. Replies:
    3
    Views:
    561
    Rolf Magnus
    Apr 13, 2008
  5. Guest
    Replies:
    0
    Views:
    448
    Guest
    Sep 14, 2005
Loading...

Share This Page