 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Jee Guest
|
Posted: Fri Sep 26, 2003 6:23 pm Post subject: pullzed at static template member function |
|
|
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
|
Posted: Fri Sep 26, 2003 7:27 pm Post subject: Re: pullzed at static template member function |
|
|
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
|
Posted: Fri Sep 26, 2003 9:21 pm Post subject: Re: pullzed at static template member function |
|
|
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
|
Posted: Fri Sep 26, 2003 9:47 pm Post subject: Re: pullzed at static template member function |
|
|
"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
|
Posted: Sat Sep 27, 2003 9:59 am Post subject: Re: pullzed at static template member function |
|
|
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
|
Posted: Sat Sep 27, 2003 6:36 pm Post subject: Re: pullzed at static template member function |
|
|
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
|
Posted: Sun Sep 28, 2003 6:24 am Post subject: Re: pullzed at static template member function |
|
|
"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 or check the STL, please code:
#include
using namespace std; or using std::vector;
|
|
| Back to top |
|
 |
|
|
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
|
|