473,386 Members | 1,786 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

template definition

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
3 1281
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: SainTiss | last post by:
Hi, If you've got a template class with lots of methods, and then you've got a type which works with the template, except for one method... What you need to do there is specialize the...
6
by: Dave | last post by:
Hello all, Consider this function template definition: template<typename T> void foo(T) {} If foo is never called, this template will never be instantiated. Now consider this explicit...
7
by: Drew McCormack | last post by:
I have a C++ template class which contains a static variable whose construction registers the class with a map. Something like this: template <typename T> class M { static Registrar<M>...
9
by: Christof Warlich | last post by:
Hi, consider this: template<typename Tclass X { public: void doSomething(T t); }; int main(void) { X<intx;
5
by: lobequadrat | last post by:
Hello, I am trying to get the following code work (unfortunately not mine ... :( ) template <class Tclass Test { public: class ELEM;
1
by: ctoo | last post by:
The following compiles and works with g++ 3.4.4 and Borland C++ Builder 6 update#4: #include <iostream> #include <vector> #include <utility> // declaration and definition for primary class...
9
by: wo3kie | last post by:
#include <iostream> #include <map> #include <utility> // // Base // / | \ // Derived1 Derived2 \ // \ | / // Derived3
6
by: Gaijinco | last post by:
I'm trying to do a template class Node. My node.hpp is: #ifndef _NODE_HPP_ #define _NODE_HPP_ namespace com { namespace mnya { namespace carlos { template <typename T>
5
by: chgans | last post by:
Hi all, I'm having difficulties with some template static member, especially when this member is a template instance, for example: ---- template<typename T> class BaseT { public: static...
6
by: Jon | last post by:
Normally I can search and find answers to things like this but with this one I'm not even sure what to search for and haven't had any luck. Anyway, I'm trying to use a template name as a template...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.