S
sonnu
I have a func template declaration in "func_template.h" header and
have the definition under "func_template.cpp" as shown below.
Questions:
1.0 How can I make use of the template declaration from a diffrent CPP
file. My intention is not to expose the implementation details to the
client code. Is this possible?
2.0 Can I make this particular template instantiation exclusive for a
single file, I mean I want to achieve what a "STATIC" keyword achieve
in C for a func decl/defn.
3.0 Can I get the list of standard compilers available which supports
this model of template instantiation?
//File func_template.h
template<typename T, int size>
T Median(T (&_m)[size]);
template<typename T, int size>
T Deviation(T (&_m)[size], T _val);
//End func_template.h
//File func_template.cpp
template<typename T, int size> <------------As C++ standard
documentation states, including "export" keyword gets compile error
T Median(T (&_m)[size])
{
//Do something
return _m[1];
}
template<typename T, int size>
T Deviation(T (&_m)[size], T _val)
{
if(size > 0)
{
//do something
}
return T(0);
}
//File consumer_temp.cpp
#include "func_template.h"
int main(int argc, char* argv[], char** _environ)
{
int rc = -1;
int trng_data[4] = {1,2,3,4,5};
int lol = Median(trng_data); <--------- Gives me Linking Error
under VS2005 compiler????
exit(rc);
}
have the definition under "func_template.cpp" as shown below.
Questions:
1.0 How can I make use of the template declaration from a diffrent CPP
file. My intention is not to expose the implementation details to the
client code. Is this possible?
2.0 Can I make this particular template instantiation exclusive for a
single file, I mean I want to achieve what a "STATIC" keyword achieve
in C for a func decl/defn.
3.0 Can I get the list of standard compilers available which supports
this model of template instantiation?
//File func_template.h
template<typename T, int size>
T Median(T (&_m)[size]);
template<typename T, int size>
T Deviation(T (&_m)[size], T _val);
//End func_template.h
//File func_template.cpp
template<typename T, int size> <------------As C++ standard
documentation states, including "export" keyword gets compile error
T Median(T (&_m)[size])
{
//Do something
return _m[1];
}
template<typename T, int size>
T Deviation(T (&_m)[size], T _val)
{
if(size > 0)
{
//do something
}
return T(0);
}
//File consumer_temp.cpp
#include "func_template.h"
int main(int argc, char* argv[], char** _environ)
{
int rc = -1;
int trng_data[4] = {1,2,3,4,5};
int lol = Median(trng_data); <--------- Gives me Linking Error
under VS2005 compiler????
exit(rc);
}