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 

template static member decl

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





PostPosted: Fri Apr 29, 2005 3:12 pm    Post subject: template static member decl Reply with quote



Hello, I'm starting to think this may be a problem with minGW.. I have a
template class with an embedded class which I want to make a static
instance member of the template outer class...

#include <vector>
#include <algorithm>
#include "time_stamp.h"
#include "frame_num.h"

using namespace ::std;

template< class M >
class notification
{
time_stamp t_stamp;
frame_num frame_no;
public:
virtual ~notification(){} //must be virtual
class router
{
router(router const &); //no copying
void operator=(router const &);
public:
.............
};
static router r;
};

template< class M >
notification<M>::router
notification<M>::r(); // HERE'S THE PROBLEM REPORTED

The invocacion is:

struct pass_int : public notification< pass_int >
{
int the_int;
};

MinGW, at the line marked above, says...
"expected constructor, destructor, or type conversion before 'notification'"
"expected ';' before 'notification'

Or am I doing something wrong?
Back to top
Shezan Baig
Guest





PostPosted: Fri Apr 29, 2005 3:38 pm    Post subject: Re: template static member decl Reply with quote




Dan W. wrote:
Quote:
template< class M
notification notification<M>::r(); // HERE'S THE PROBLEM REPORTED


This should be:

template< class M >
notification<M>::router notification<M>::r;


(i.e., without the '()').

hope this helps,
-shez-


Back to top
Shezan Baig
Guest





PostPosted: Fri Apr 29, 2005 3:40 pm    Post subject: Re: template static member decl Reply with quote



Quote:
template< class M
notification


Sorry, you also need 'typename':

template< class M >
typename notification<M>::router notification<M>::r;


Hope this helps,
-shez-


Back to top
Dan W.
Guest





PostPosted: Fri Apr 29, 2005 4:10 pm    Post subject: Re: template static member decl Reply with quote

Yes, that did it! Thanks a million. Good catch with the parenthesis.
They were a more recent typo, though; got the same problem after
removing them; but 'typename' was it. Hard to get my head around why I
need it, though...

Shezan Baig wrote:

Quote:
template< class M
notification


Sorry, you also need 'typename':

template< class M
typename notification

Hope this helps,
-shez-


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.