VC++6 function template problem

R

Ricky Lung

VC++6 doesn't let me call the templated function with explicit template
parameter, how to solve it? Any tricks? Thanks.

class Foo {
public:
template<typename T>
T test() {
return T(0);
}
};

int main()
{
Foo foo;
int a = foo.test<int>(); // <-- Failed here
return 0;
}


~ Let us linux ~
 
R

Rob Williscroft

Ricky Lung wrote in
VC++6 doesn't let me call the templated function with explicit template
parameter, how to solve it? Any tricks? Thanks.

Upgrade your compiler :) (VC6.0 is very old now).
class Foo {
public:
template<typename T>
T test() {

T test( T * ) {
return T(0);
}
};

int main()
{
Foo foo;
int a = foo.test<int>(); // <-- Failed here

int a = foo.test( (int *)0 );
return 0;
}

IIUC the above is the only workarounfd for this defect in VC6.0.

Rob.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,160
Messages
2,570,889
Members
47,422
Latest member
LatashiaZc

Latest Threads

Top