does value-initialization happen for global and local static object ?

Discussion in 'C++' started by subramanian100in@yahoo.com, India, Apr 20, 2008.

  1. , India

    , India Guest

    Suppose I have

    #include <cstdlib>
    #include <iostream>

    using namespace std;

    class Test
    {
    public:
    int i;
    double d;
    char* str;
    };

    Test obj;

    int main()
    {
    static Test one;
    return EXIT_SUCCESS;
    }

    Will the global 'Test obj' and the local static 'Test one' be value-
    initialized ?
    What does the C++ standard say in this regard ?

    Kindly clarify.

    Thanks
    V.Subramanian
     
    , India, Apr 20, 2008
    #1
    1. Advertising

  2. , India

    , India Guest

    Re: does value-initialization happen for global and local staticobject ?

    On Apr 20, 1:43 am, "Alf P. Steinbach" <> wrote:
    > * , India:
    >
    > They're zero-initialized.
    >
    > This happens before any dynamic initialization.
    >
    > Cheers, & hth.,
    >
    > - Alf


    Is zero-initialization different from value_initialization ?

    What is meant by dynamic initialization ?

    Kindly explain ?

    Thanks
    V.Subramanian
     
    , India, Apr 21, 2008
    #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. Patrick Hoffmann
    Replies:
    3
    Views:
    2,841
    Christian Jan├čen
    Aug 8, 2003
  2. tropos
    Replies:
    3
    Views:
    465
  3. Jess
    Replies:
    23
    Views:
    931
  4. Ali
    Replies:
    4
    Views:
    908
  5. AlexWalk
    Replies:
    2
    Views:
    731
    AlexWalk
    Jun 23, 2010
Loading...

Share This Page