Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
重複の可能性: Aggregate と POD とは何ですか? また、どのように/なぜそれらが特別なのですか?
C++ 11 の構造体は、この構造体を POD として保持するためにどのようなコンストラクターを使用できますか?
初期化子リストのみが受け入れられますか? それとも何の制限もないのでしょうか?
自明であるように、デフォルトのデフォルトコンストラクターが必要です。
struct pot { constexpr pot() noexcept = default; pot(int a, float b) : x(a), y(b) { } int x; float y; };
constexprとnoexceptはオプションですが、そうする場合もあります。
constexpr
noexcept
使用法:
pot p; // OK pot q(1, 1.5); // also OK