Guest User

Untitled

a guest
Aug 19th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. using templates with vectors and vector functions
  2. std::vector<Word> concordance = push_vector(data);
  3.  
  4. template <typename T>
  5. std::vector<T> push_vector(std::string&);
  6.  
  7. main.cpp: In function ‘int main(int, char**)’:
  8. main.cpp:27:53: error: no matching function for call to ‘push_vector(std::string&)’
  9. main.cpp:27:53: note: candidate is:
  10. templates.h:13:20: note: template<class T> std::vector<T> push_vector(std::string&)
  11.  
  12. template <typename T>
  13. void push_vector(const std::string& str, std::vector<T>& vec)
  14. {
  15. // convert str to T if possible
  16. // throw on failure maybe?
  17. // assign vec with converted data
  18. }
  19.  
  20. std::string data("Hello");
  21. std::vector<Word> concordance;
  22. push_vector(data, concordance);
  23.  
  24. std::vector<Word> concordance = push_vector<Word>(data);
Add Comment
Please, Sign In to add comment