B
Bas
Explicit specialization only allowed at file or namespace scope" .. is the
error I got from a compiler. Another compiler doesn't
complain.
Who is right?
Thanks on forehand,
Bas
#include <iostream>
class Test
{
public:
int x,y;
Test(int a, int b) : x(a), y(b) {};
template<typename x>
x telop(x a, x b)
{
return a + b;
}
template<> // One doesn't like this one.
int telop<int>(int a, int b)
{
return (a + b) * 10;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Test t(3.14, 4.545);
std::cout << t.telop<int>(3.14, 4.545);
std::cin.get();
return 0;
}
error I got from a compiler. Another compiler doesn't
complain.
Who is right?
Thanks on forehand,
Bas
#include <iostream>
class Test
{
public:
int x,y;
Test(int a, int b) : x(a), y(b) {};
template<typename x>
x telop(x a, x b)
{
return a + b;
}
template<> // One doesn't like this one.
int telop<int>(int a, int b)
{
return (a + b) * 10;
}
};
int _tmain(int argc, _TCHAR* argv[])
{
Test t(3.14, 4.545);
std::cout << t.telop<int>(3.14, 4.545);
std::cin.get();
return 0;
}