fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct A
  5. {
  6. int a_;
  7. };
  8.  
  9. struct B : public A
  10. {
  11. int b_;
  12. };
  13.  
  14. void test(A a[])
  15. {
  16. cout << a[0].a_ << endl;
  17. cout << a[1].a_ << endl;
  18. }
  19.  
  20.  
  21. int main() {
  22. // your code goes here
  23. B b[1];
  24. b[0].a_ = 123;
  25. b[0].b_ = 456;
  26. test(b);
  27.  
  28. return 0;
  29. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
123
456