fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. class pub
  6. {
  7. public:
  8. pub(const std::string& a_name) : name_(a_name) {}
  9. std::string name() const { return name_; }
  10. private:
  11. std::string name_;
  12. };
  13. int main()
  14. {
  15. std::vector<pub> v = { pub("1"), pub("2") };
  16.  
  17. std::cout << v[0].name() << ", " << v[1].name() << "\n";
  18. return 0;
  19. }
  20.  
  21.  
Success #stdin #stdout 0s 3020KB
stdin
Standard input is empty
stdout
1, 2