考虑代码VS2013列表初始化
#include "stdafx.h"
#include <Windows.h>
#include <iostream>
struct B
{
public:
void f() { for (auto &v : member) { std::cout << v << std::endl; } }
private:
int member[100];
};
int main()
{
B b{};
b.f();
}
我觉得这个码是$ 8.5.4/3
List-initialization of an object or reference of type T is defined as follows: — If the initializer list has no elements and T is a class type with a default constructor, the object is value-initialized.
引导取而代之的是VS2013编译器发出的所有0xCCCCCCCC这意味着它留下的所有元素b.成员未初始化。所以,它似乎正在执行默认初始化而不是数值初始化。
请让我知道如果我失去了一些东西。
是不是当你有一个DEBUG编译? –