Machine Gun Confusion

Not sure about the appropriate heading, but this follows from this discussion:

Are parentheses made after the type name with a new one?

In Visual Studio 2008, when I run the following code:

struct Stan
{
    float man;
};

int main()
{
    Stan *s1 = new Stan;
    Stan *s2 = new Stan();

}

Studying locals, s1 has an uninitialized float with a random value. s2 is the value initialized to 0.

However, if I add a string data element, the float is not initialized in both cases.

struct Stan
    {
            std::string str;
        float man;
    }; 

. -POD- , , . , - POD? POD, , , ? , ( , ) , ?

+3
2

POD, POD non-POD-struct std::string ( ) , , -POD-struct.

/ Visual Studio 2008. ++ 03 -POD-, .

, , , float new Stan, new Stan().

, .

.

+5

, , ++ 98.

- POD ( ). () POD, .

POD (- -POD str). () -POD, . , , str, man, .

, ++ 98. ++ 03. ++ 03 () . man () .

. fooobar.com/questions/72/... .

0

Source: https://habr.com/ru/post/1728778/


All Articles