fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct B {
  5. int number;
  6. B(int n) : number(n) { }
  7. };
  8.  
  9. class A {
  10. private:
  11. B *myArray;
  12. public:
  13. A() { myArray = new B[1]{5}; }
  14. void print() { std::cout << myArray[0].number << std::endl; }
  15. };
  16.  
  17. int main() {
  18. A a;
  19. a.print();
  20.  
  21. return 0;
  22. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
5