fork download
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. struct my_str {
  5. int x;
  6. my_str() {
  7. x = 0;
  8. }
  9. void insert();
  10. };
  11. vector<my_str> p;
  12.  
  13. void my_str :: insert() {
  14. p.push_back(my_str());
  15. x = 123;
  16. }
  17.  
  18. int main() {
  19. p.push_back(my_str());
  20. p[0].insert();
  21. cout << p[0].x << "\n";
  22. return 0;
  23. }
Success #stdin #stdout 0s 3428KB
stdin
Standard input is empty
stdout
0