{"title":"non-static data member initializer \u3068\u521d\u671f\u5316\u5b50\u30ea\u30b9\u30c8\u306e\u512a\u5148\u5ea6","description":"C++11 \u304b\u3089\u30c7\u30fc\u30bf\u30e1\u30f3\u30d0\u5ba3\u8a00\u5834\u6240\u3067\u975e\u9759\u7684\u30e1\u30f3\u30d0\u306e\u521d\u671f\u5316\u304c\u51fa\u6765\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u304c\uff0c\u3053\u306e\u521d\u671f\u5316\u306f\u521d\u671f\u5316\u5b50\u30ea\u30b9\u30c8\u306b\u3088\u308b\u521d\u671f\u5316\u304c\u7701\u7565\u3055\u308c\u305f\u3068\u304d\u306e\u307f\u884c\u308f\u308c\u307e\u3059\uff0e #include <iostream> struct X{ int const i = 42; X(){} // \u521d\u671f\u5316\u5b50\u30ea\u30b9\u30c8\u7121\u3057 X(char) : i(-42){} // \u521d\u671f\u5316\u5b50\u30ea\u30b9\u30c8\u6709\u308a }; int main() { X x1{}; // \u521d\u671f\u5316\u5b50\u30ea\u30b9\u30c8\u7121\u3057 std::cout << x1.i << '\\n'; // 42 X x2{'a'}; // \u521d\u671f\u5316\u5b50\u30ea\u30b9\u30c8\u6709\u308a std::cout << x2.i << '\\n'; /\u2026","blog_url":"https://rhysd.hatenablog.com/","categories":["C++"],"height":"190","provider_name":"Hatena Blog","provider_url":"https://hatena.blog","type":"rich","width":"100%","author_name":"rhysd","author_url":"https://blog.hatena.ne.jp/rhysd/","version":"1.0","url":"https://rhysd.hatenablog.com/entry/2013/07/05/220734","image_url":null,"blog_title":"\u306f\u3084\u304f\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u306a\u308a\u305f\u3044","published":"2013-07-05 22:07:34","html":"<iframe src=\"https://hatenablog-parts.com/embed?url=https%3A%2F%2Frhysd.hatenablog.com%2Fentry%2F2013%2F07%2F05%2F220734\" title=\"non-static data member initializer \u3068\u521d\u671f\u5316\u5b50\u30ea\u30b9\u30c8\u306e\u512a\u5148\u5ea6 - \u306f\u3084\u304f\u30d7\u30ed\u30b0\u30e9\u30e0\u306b\u306a\u308a\u305f\u3044\" class=\"embed-card embed-blogcard\" scrolling=\"no\" frameborder=\"0\" style=\"display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;\"></iframe>"}