J
Jim Langston
This should illistrate what I am trying to do:
template <class T>
T SomeFunction( T parm )
{
return parm;
}
template <class T>
class SomeClass
{
public:
SomeClass( T fp ) {}
};
int main()
{
int x = 0;
SomeFunction( x );
// SomeClass sf( x ); // Won't work
SomeClass<int> sf( x );
}
I'm trying to instantize a templated class without having to specify the
template argument. I can do that for templated functions as shown. When
trying to compile for classes, however, I'm told that:
error C2955: 'SomeClass' : use of class template requires template argument
list
For this simple type of int illistrating the problem, it's no big deal. All
I have to do is add <int>. But what I'm actually trying to do is come up
with a way to store function pointers in a class which this is the first
piece of. I'm don't want to have to figure out if it's int (*)( float,
double, std::string).
I mean, I can in a fuction pass the name of a function and even call it in a
function (with no parms at this point) and I don't have to type in code the
template argument.
template <class T>
T SomeFunction( T parm )
{
return parm;
}
template <class T>
class SomeClass
{
public:
SomeClass( T fp ) {}
};
int main()
{
int x = 0;
SomeFunction( x );
// SomeClass sf( x ); // Won't work
SomeClass<int> sf( x );
}
I'm trying to instantize a templated class without having to specify the
template argument. I can do that for templated functions as shown. When
trying to compile for classes, however, I'm told that:
error C2955: 'SomeClass' : use of class template requires template argument
list
For this simple type of int illistrating the problem, it's no big deal. All
I have to do is add <int>. But what I'm actually trying to do is come up
with a way to store function pointers in a class which this is the first
piece of. I'm don't want to have to figure out if it's int (*)( float,
double, std::string).
I mean, I can in a fuction pass the name of a function and even call it in a
function (with no parms at this point) and I don't have to type in code the
template argument.