D
Dave
Hello all,
I am trying to create a full specialization of a member function template of
a class template. I get the following errors:
Line 29: 'foo<T1>::bar' : illegal use of explicit template arguments
Line 29: 'bar' : unable to match function definition to an existing
declaration
What am I doing wrong?
Thanks,
Dave
#include <iostream>
using namespace std;
template <typename T1>
class foo
{
public:
template <typename T2>
void bar(const T2 ¶m);
};
template <typename T1>
template <typename T2>
void foo<T1>::bar(const T2 ¶m)
{
static_cast<void>(param);
cout << "Point 1" << endl;
}
template <typename T1>
template <>
void foo<T1>::bar<double>(const double ¶m)
{
static_cast<void>(param);
cout << "Point 2" << endl;
}
int main()
{
foo<int> var;
var.bar(4.5);
}
I am trying to create a full specialization of a member function template of
a class template. I get the following errors:
Line 29: 'foo<T1>::bar' : illegal use of explicit template arguments
Line 29: 'bar' : unable to match function definition to an existing
declaration
What am I doing wrong?
Thanks,
Dave
#include <iostream>
using namespace std;
template <typename T1>
class foo
{
public:
template <typename T2>
void bar(const T2 ¶m);
};
template <typename T1>
template <typename T2>
void foo<T1>::bar(const T2 ¶m)
{
static_cast<void>(param);
cout << "Point 1" << endl;
}
template <typename T1>
template <>
void foo<T1>::bar<double>(const double ¶m)
{
static_cast<void>(param);
cout << "Point 2" << endl;
}
int main()
{
foo<int> var;
var.bar(4.5);
}