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 

pullzed at static template member function

 
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++)
View previous topic :: View next topic  
Author Message
Jee
Guest





PostPosted: Fri Sep 26, 2003 6:23 pm    Post subject: pullzed at static template member function Reply with quote



Hi,

I want to declare a static template member function inside a non-template class, but MS C compiler always

complains syntax error. I wonder if it is not allowed to do that? I tried SUN Forte compiler, it errored also.

My class is like,

class a{

public:

static template<class T> vector<T> getIntersection(vector<T>&, vector<T>&);

};

Could you point me what's wrong here?



Back to top
Simon Saunders
Guest





PostPosted: Fri Sep 26, 2003 7:27 pm    Post subject: Re: pullzed at static template member function Reply with quote



On Fri, 26 Sep 2003 12:23:12 -0600, Jee wrote:

Quote:
Hi,

I want to declare a static template member function inside a non-template class, but MS C compiler always

complains syntax error. I wonder if it is not allowed to do that? I tried SUN Forte compiler, it errored also.

My class is like,

class a{

public:

static template<class T> vector<T> getIntersection(vector<T>&, vector<T>&);

};

Could you point me what's wrong here?



class a
{
public:
template<class T>
static vector<T> getIntersection(vector<T>&, vector<T>&);
};


Back to top
Jee
Guest





PostPosted: Fri Sep 26, 2003 9:21 pm    Post subject: Re: pullzed at static template member function Reply with quote



Simon Saunders wrote:

Quote:
On Fri, 26 Sep 2003 12:23:12 -0600, Jee wrote:

Hi,

I want to declare a static template member function inside a non-template class, but MS C compiler always

complains syntax error. I wonder if it is not allowed to do that? I tried SUN Forte compiler, it errored also.

My class is like,

class a{

public:

static template<class T> vector<T> getIntersection(vector<T>&, vector<T>&);

};

Could you point me what's wrong here?



class a
{
public:
template<class T
static vector };

I tried this, I got the same error, in MSC the error is
error C2143: syntax error: missing ';' before '<'.

and in Forte the error is
Templates can only declare class and function.


Still puzzled...



Back to top
Russell Hanneken
Guest





PostPosted: Fri Sep 26, 2003 9:47 pm    Post subject: Re: pullzed at static template member function Reply with quote

"Jee" <jee (AT) hotmail (DOT) com> wrote

Quote:
Simon Saunders wrote:

class a
{
public:
template<class T
static vector };

I tried this, I got the same error, in MSC the error is
error C2143: syntax error: missing ';' before '<'.

and in Forte the error is
Templates can only declare class and function.

Did you #include std::vector;"?

This complete example compiles for me with Visual C++ .NET (2002):

#include <vector>

using std::vector;

class a
{
public:
template<class T>
static vector<T> getIntersection(vector<T>&, vector<T>&);
};

--
Russell Hanneken
[email]rghanneken (AT) pobox (DOT) com[/email]
Remove the 'g' from my address to send me mail.




Back to top
DarkSpy
Guest





PostPosted: Sat Sep 27, 2003 9:59 am    Post subject: Re: pullzed at static template member function Reply with quote

right code is:
class a{

public:

template<class T> static vector<T> getIntersection(vector<T>&, vector<T>&);

};

Jee <jee (AT) hotmail (DOT) com> wrote

Quote:
Hi,

I want to declare a static template member function inside a non-template class, but MS C compiler always

complains syntax error. I wonder if it is not allowed to do that? I tried SUN Forte compiler, it errored also.

My class is like,

class a{

public:

static template<class T> vector<T> getIntersection(vector<T>&, vector<T>&);

};

Could you point me what's wrong here?



--

Back to top
Kevin Goodsell
Guest





PostPosted: Sat Sep 27, 2003 6:36 pm    Post subject: Re: pullzed at static template member function Reply with quote

DarkSpy wrote:

Quote:
right code is:
snip


Please don't top-post. Read section 5 of the FAQ for posting guidelines.

http://www.parashift.com/c++-faq-lite/

-Kevin
--
My email address is valid, but changes periodically.
To contact me please use the address from a recent posting.


Back to top
DarkSpy
Guest





PostPosted: Sun Sep 28, 2003 6:24 am    Post subject: Re: pullzed at static template member function Reply with quote

"Russell Hanneken" <rghanneken (AT) pobox (DOT) com> wrote

Quote:
"Jee" <jee (AT) hotmail (DOT) com> wrote in message
news:3F74ADF7.F1A87A82 (AT) hotmail (DOT) com...
Simon Saunders wrote:

class a
{
public:
template<class T
static vector };

I tried this, I got the same error, in MSC the error is
error C2143: syntax error: missing ';' before '<'.


sorry about my answer with above.

if you got error, please check the MSC's version, maybe it is not
enough modern to compile this code Smile or check the STL, please code:
#include using namespace std; or using std::vector;

Back to top
Display posts from previous:   
Post new topic   Reply to topic    C++Talk.NET Forum Index -> C++ language (comp.lang.c++) 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.