Quantcast
Channel: CodeGuru Forums - Visual C++ Programming
Viewing all articles
Browse latest Browse all 3029

Function Template and vector

$
0
0
Hi,

I'm trying to figure out how to use a generic function template to simply return a vector array of ints or doubles or whatever else I want.

Here is the code:

  1. template <typename T>
  2. std::vector<T> myVec(T s, T e, T v)
  3. {
  4. std::vector<T> C;
  5. for (s; s <= e; s += v) { C.push_back(s); }
  6. return C;
  7. }
  8. main()
  9. {
  10. std::vector<int> V = myVec<int>(1,10,1);
  11. }



It gives me a linker error to this function when it compiles. Can anyone please help?

Thank you.

Viewing all articles
Browse latest Browse all 3029

Latest Images

Trending Articles



Latest Images