By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,797 Members | 1,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,797 IT Pros & Developers. It's quick & easy.

template definition

P: n/a
template <typename T>
class tt
{
vector<Tvect;
inline void add(const T & t);
}

Can I define the member function "inline void add(const T & t)"
outside the class interface in the header file?How?
Thanks in advance.

Feb 20 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
On Feb 20, 12:49 pm, "antani" <antani8...@yahoo.itwrote:
template <typename T>
class tt
{
vector<Tvect;
inline void add(const T & t);

}

Can I define the member function "inline void add(const T & t)"
outside the class interface in the header file?How?
Not sure I understand you correctly, but is this what you want?

template <typename T>
class tt
{
vector<Tvect;
inline void add(const T & t);

};

template<typename T>
void tt::add(const T& t)
{
// do stuff
}

--
Erik Wikström

Feb 20 '07 #2

P: n/a
On Feb 20, 2:11 pm, "Erik Wikström"
<eri...@student.chalmers.sewrote:
On Feb 20, 12:49 pm, "antani" <antani8...@yahoo.it>
wrote:
template <typename T>
class tt
{
vector<Tvect;
inline void add(const T & t);
}
Can I define the member function "inline void
add(const T & t)" outside the class interface in the
header file?How?

template<typename T>
void tt::add(const T& t)
{
// do stuff
}
Shouldn't this be more like this?

template<typename T>
void tt<T>::add(const T& t)
{
// do stuff
}

--
Pavel Lepin

Feb 20 '07 #3

P: n/a
On Feb 20, 2:06 pm, p.le...@ctncorp.com wrote:
On Feb 20, 2:11 pm, "Erik Wikström"

<eri...@student.chalmers.sewrote:
On Feb 20, 12:49 pm, "antani" <antani8...@yahoo.it>
wrote:
template <typename T>
class tt
{
vector<Tvect;
inline void add(const T & t);
}
Can I define the member function "inline void
add(const T & t)" outside the class interface in the
header file?How?
template<typename T>
void tt::add(const T& t)
{
// do stuff
}

Shouldn't this be more like this?

template<typename T>
void tt<T>::add(const T& t)
{
// do stuff

}
Oops, sorry, yes that is correct.

--
Erik Wikström

Feb 20 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.