B
Bas
Hello everybody,
I've tried this small program, but ik get the compiler error:
Error 1 error C2768: 'functie' : illegal use of explicit template arguments
d:\projects\templatespectest\templatespectest\templatespectest.cpp 17
on the second template specialisation. I do not understand why.
The rest of the templates are OK.
thanks, Bas From Holland
#include <iostream>
template<class T> int functie(T val)
{
T temp = val;
return 0;
}
template<class T> int functie<T*>(T* val)
{
T* temp = val;
return 0;
}
template<> int functie<void*>(void* val)
{
void* temp = val;
return 0;
}
template<> int functie<int *>(int* val)
{
int* temp = val;
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
int p = 0;
void* pV = 0;
functie<int>(p);
functie<int*>(&p);
functie<void*>(pV);
std::cin.get();
return 0;
}
I've tried this small program, but ik get the compiler error:
Error 1 error C2768: 'functie' : illegal use of explicit template arguments
d:\projects\templatespectest\templatespectest\templatespectest.cpp 17
on the second template specialisation. I do not understand why.
The rest of the templates are OK.
thanks, Bas From Holland
#include <iostream>
template<class T> int functie(T val)
{
T temp = val;
return 0;
}
template<class T> int functie<T*>(T* val)
{
T* temp = val;
return 0;
}
template<> int functie<void*>(void* val)
{
void* temp = val;
return 0;
}
template<> int functie<int *>(int* val)
{
int* temp = val;
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
int p = 0;
void* pV = 0;
functie<int>(p);
functie<int*>(&p);
functie<void*>(pV);
std::cin.get();
return 0;
}