| View previous topic :: View next topic |
| Author |
Message |
Quick Function Guest
|
Posted: Thu Jul 22, 2004 10:57 pm Post subject: static template method how to access |
|
|
class A
{
template<class Type> static void do(Type a){
...
}
};
When I use:
Person p;
A:do(p);
VC++ 6.0 reports "Failed to specialize function template". How can I
access the static template method?
Thanks,
qq
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
Daniel Krügler (ne Spange Guest
|
Posted: Fri Jul 23, 2004 10:05 am Post subject: Re: static template method how to access |
|
|
Good mroning,
Quick Function schrieb:
| Quote: | class A
{
template<class Type> static void do(Type a){
...
}
};
When I use:
Person p;
A:do(p);
VC++ 6.0 reports "Failed to specialize function template". How can I
access the static template method?
You example contains several errors: |
1) The keyword "do" is not allowed to be a name of user-defined entity -
lets rename it do_
2) The function A:::do_ has the default private access rights and thus
cannot be used outside
of the A namespace/"friendship-space". Lets fix it to use public access
3) The expressin A:do_(p); is invalid lets fix it to A::do_(p);
We end with:
class A
{
public:
template<class Type> static void do_(Type a){
}
};
void foo() {
Person p;
A::do_(p);
}
which successfully compiles (even on VC6...)
HTH,
Daniel Krügler
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]
|
|
| Back to top |
|
 |
|