1

I'm trying the following:

struct A
{
    int x;
};

struct B: A
{
    int y;
};

B foo = {1, 2};

But I get:

error: could not convert '{1, 2}' from '<brace-enclosed initializer list>' to 'B'

This is using C++11. Can I get round it without defining an explicit constructor?

Stefan
  • 8,819
  • 10
  • 42
  • 68

0 Answers0