0

Given:

struct Foo { int a; int b; };
struct Bar { Foo foo; int c; };

Is this well-defined?

void f(Bar *bar) {
    auto foo = (Foo*)bar;
    cout << foo->a << ',' << foo->b;
}

Clang translates code using inheritance, to the equivalent of the above, but I want to make sure it's defined by the standard.

rwallace
  • 28,614
  • 33
  • 112
  • 214

0 Answers0