fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. struct NoDefCtor
  6. {
  7. std::string s;
  8. NoDefCtor(const char *str) : s(str)
  9. {
  10. }
  11. };
  12.  
  13. int main()
  14. {
  15. std::vector<NoDefCtor> v;
  16. v.push_back("Hello, ");
  17. v.push_back("World!");
  18. for(std::size_t i = 0; i < v.size(); ++i)
  19. {
  20. std::cout << v[i].s << std::flush;
  21. }
  22. }
Success #stdin #stdout 0s 2988KB
stdin
Standard input is empty
stdout
Hello, World!