Question about Pointer to Member Typedefs inside templates



 DEVELOP > c-Plus-Plus > Question about Pointer to Member Typedefs inside templates

LINK TO THIS PAGE  


rating :  0   |  0


  Page 1 of 1

1

 
Topic: DEVELOP > c-Plus-Plus
User: ""
Date: 25 Jan 2008 11:48:17 AM
Object: Question about Pointer to Member Typedefs inside templates
Hi,
Can anyone please tell me why this code is giving me a C2327 error? I
am using Visual C++ 2008.
template<class T, int T::*IntMemberOfT>
class Foo
{
};
class Bar
{
public:
int memberOfBar;
typedef Foo<Bar, &Bar::memberOfBar> TypeDefedFooBar;
};
The errors I see are:
error C2327: 'Bar::memberOfBar' : is not a type name, static, or
enumerator => Why am I seeing this one?
error C2065: 'memberOfBar' : undeclared identifier => This one will
probably go away once C2327 is gone.
If I move the type definition outside of Bar's scope it compiles
successfully.
Thanks
Waseem
.

User: "Victor Bazarov"

Title: Re: Question about Pointer to Member Typedefs inside templates 25 Jan 2008 01:18:34 PM
wrote:

Can anyone please tell me why this code is giving me a C2327 error? I
am using Visual C++ 2008.

template<class T, int T::*IntMemberOfT>
class Foo
{
};

class Bar
{
public:
int memberOfBar;
typedef Foo<Bar, &Bar::memberOfBar> TypeDefedFooBar;
};

The errors I see are:
error C2327: 'Bar::memberOfBar' : is not a type name, static, or
enumerator => Why am I seeing this one?
error C2065: 'memberOfBar' : undeclared identifier => This one will
probably go away once C2327 is gone.

If I move the type definition outside of Bar's scope it compiles
successfully.

There seems to be no specific difference except that if you move
the typedef outside, 'Bar' is now a complete type. It can just
be a bug in the compiler. You should probably ask in the Visual
C++ newsgroup as well.
Try compiling your test program with online Comeau trial. If it
compiles it successfully, mention that in the VC++ newsgroup.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
.


  Page 1 of 1

1

 


Related Articles
 

NEWER

pg.1232     pg.940     pg.716     pg.544     pg.412     pg.311     pg.234     pg.175     pg.130     pg.96     pg.70     pg.50     pg.35     pg.24     pg.16     pg.10     pg.6     pg.3     pg.1

OLDER