Initialization and Memory

Discussion in 'C++' started by Chris Forone, Jun 12, 2012.

  1. Chris Forone

    Chris Forone Guest

    Hello,

    if i write code like this:

    #include <vector>

    int main()
    {
    float big[] =
    {
    1.0f, 2.0f, 3.0f
    };

    std::vector<float> v(big, big + sizeof(big) / sizeof(big[0]));
    }

    are the floats twice in memory (one time from the literals, one time as
    copies in the vector)? do compilers free initialisation memory after
    initialization?

    thanks for your short answer,
    chris
    Chris Forone, Jun 12, 2012
    #1
    1. Advertising

  2. Chris Forone

    Chris Forone Guest

    Am 12.06.2012 07:44, schrieb Chris Forone:
    > Hello,
    >
    > if i write code like this:
    >
    > #include <vector>
    >
    > int main()
    > {
    > float big[] =
    > {
    > 1.0f, 2.0f, 3.0f
    > };
    >
    > std::vector<float> v(big, big + sizeof(big) / sizeof(big[0]));
    > }
    >
    > are the floats twice in memory (one time from the literals, one time as
    > copies in the vector)? do compilers free initialisation memory after
    > initialization?
    >
    > thanks for your short answer,
    > chris


    sorry for the multi-post.
    Chris Forone, Jun 12, 2012
    #2
    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. JKop
    Replies:
    10
    Views:
    937
  2. Matthias Kaeppler
    Replies:
    2
    Views:
    437
    Victor Bazarov
    Jul 18, 2005
  3. Jess
    Replies:
    23
    Views:
    926
  4. Replies:
    5
    Views:
    1,970
    Arne Mertz
    Mar 26, 2009
  5. Taras_96
    Replies:
    3
    Views:
    583
    Michael Tsang
    Oct 30, 2009
Loading...

Share This Page