F
Floogle
How come I get a "error C2062: type 'int' unexpected" error with the
second version?
Is it possible to achieve the same functiuonaility as the fn as a
class method?
Many thanks
//this is ok
template <class T>
T* CreateAnInstanceFn()
{
return new T();
}
//but this isn't
class MyClass
{
public:
template <class T>
T* CreateAnInstance()
{
return new T();
}
};
int main()
{
//legal
int* j = CreateAnInstanceFn<int>();
//uh oh!
MyClass mc;
int* i = mc.CreateAnInstance<int>();
return 0;
}
second version?
Is it possible to achieve the same functiuonaility as the fn as a
class method?
Many thanks
//this is ok
template <class T>
T* CreateAnInstanceFn()
{
return new T();
}
//but this isn't
class MyClass
{
public:
template <class T>
T* CreateAnInstance()
{
return new T();
}
};
int main()
{
//legal
int* j = CreateAnInstanceFn<int>();
//uh oh!
MyClass mc;
int* i = mc.CreateAnInstance<int>();
return 0;
}