problems making a vector of type vector<T> (ie, template)

Hi,

I can't seem to make a vector<T> in the private section of a class, even though I declare template<class T> at the beginning of the class. Totally new to this template stuff, so any suggestions will be a help.

Here's my code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;

class Sorter
{
public:

    template<class T>  // <-- here T is defined
    Sorter();

    void sortValues();

    void outputValues();

private:
    vector<T> values;  // <-- here VS 2010 says "T is undefined."
}



Thanks, guys, for the help.
1
2
3
4
5
6
7
template<class T> //here we say that our class is a template
class Sorter{
public:
   //...
private:
   std::vector<T> values; //don't `using namespace std' in headers
};
It's weird that it owns the vector.
Awesome! that fixed it.

Thank-you for the input.
:)
Topic archived. No new replies allowed.