 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Dan W. Guest
|
Posted: Fri Apr 29, 2005 3:12 pm Post subject: template static member decl |
|
|
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
|
Posted: Fri Apr 29, 2005 3:38 pm Post subject: Re: template static member decl |
|
|
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
|
Posted: Fri Apr 29, 2005 3:40 pm Post subject: Re: template static member decl |
|
|
| 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
|
Posted: Fri Apr 29, 2005 4:10 pm Post subject: Re: template static member decl |
|
|
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 |
|
 |
|
|
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
|
|