template definition

A

antani

template <typename T>
class tt
{
vector<T> vect;
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.
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

template <typename T>
class tt
{
vector<T> vect;
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<T> vect;
inline void add(const T & t);

};

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

p.lepin

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
}
 
?

=?iso-8859-1?q?Erik_Wikstr=F6m?=

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,822
Latest member
israfaceZa

Latest Threads

Top