C++Talk.NET Forum Index C++Talk.NET
C++ language newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

static template method how to access

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated)
View previous topic :: View next topic  
Author Message
Quick Function
Guest





PostPosted: Thu Jul 22, 2004 10:57 pm    Post subject: static template method how to access Reply with 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?

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





PostPosted: Fri Jul 23, 2004 10:05 am    Post subject: Re: static template method how to access Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ Language (Moderated) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.