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
  • 31,405
  • 40
  • 123
  • 242

0 Answers0