template static member decl

D

Dan W.

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?
 
S

Shezan Baig

Dan said:
template< class M >
notification<M>::router
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-
 
S

Shezan Baig

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


Sorry, you also need 'typename':

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


Hope this helps,
-shez-
 
D

Dan W.

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...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top