1

Possible Duplicate:
What are Aggregates and PODs and how/why are they special?

What kind of constructors can structs in C++11 have to keep this struct as POD?

Only initializer-list acceptable? Or maybe there are no any restrictions?

Community
  • 1
  • 1
FrozenHeart
  • 19,844
  • 33
  • 126
  • 242

1 Answers1

1

You need a defaulted default constructor so that it is trivial:

struct pot
{
    constexpr pot() noexcept = default;

    pot(int a, float b) : x(a), y(b) { }

    int x;
    float y;
};

The constexpr and noexcept are optional, but we might as well.

Usage:

pot p;         // OK
pot q(1, 1.5); // also OK
Kerrek SB
  • 464,522
  • 92
  • 875
  • 1,084