template namespace

The following questions are from a purely pedagogical view: When a class or function is created using a template and this template is such that it can be used to handle strings, should you add #include <string> at the top of the header file? Also, should you add a 'using std::string'?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// foo.h
#ifndef SOMECLASS_H_
#define SOMECLASS_H_

// FOLLOWING NECESSARY?
//#include <string>
//using std::string;  

template <typename T>
class foo
{
public;
foo(T item);
~foo();
T someFunc();
private:
T m_item;
}; /* end class foo */

template <typename T>
foo::foo(T item) : m_item(item) {}
foo::~foo() {}
T foo::someFunc() { ... }


#endif /* SOMECLASS_H_ */ 


As always, thanks in advance.
You should not include <string> in foo.h just because T can be std::string. If in some other file you use foo<std::string> you include <string> in that file instead.
thanks!!
Topic archived. No new replies allowed.