fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. class dog
  9. {
  10. public:
  11. dog(const string name) : m_name(name) {}
  12. string getName() const { return m_name; }
  13. private:
  14. string m_name;
  15. };
  16.  
  17. vector<string> getListOfDogNames()
  18. {
  19. return vector<string>{"Spike", "Spot", "George", "Shadow"};
  20. }
  21.  
  22. int main()
  23. {
  24. vector<string> dogNames = getListOfDogNames();
  25. vector<dog> dogs(dogNames.begin(), dogNames.end());
  26. for(auto &d: dogs) {
  27. cout << d.getName() << endl;
  28. }
  29. return 0;
  30. }
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
Spike
Spot
George
Shadow