Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   Does the typename keyword make sense here? (http://www.velocityreviews.com/forums/t288013-does-the-typename-keyword-make-sense-here.html)

Exits Funnel 01-08-2005 06:43 AM

Does the typename keyword make sense here?
 
Hello,

I've inherited a bunch of C++ code which was developed on Windows and
I'm in the process of trying to port it to Linux/g++. The following is
similar to one very small piece of the code:

//Begin test1.cpp
template<class B>
class CHB
{ };

template <typename B>

struct BCBT
{
typedef typename CHB<B> BCB;
};
//End test1.cpp

When I try to compile the above, g++ complains thusly:

test1.cpp:9 syntax error before ';' token.

Presumably, this code compiles under MS Visual Studio 7.1. If I remove
the 'typename' from line nine, it's compilable under g++. Two questions
then:

1) Is it legal. In other words, should g++ complain?
2) If it is legal, what does it do? It's not clear to me what purpose
typname would serve in this particular context.

Thanks!

-exits


Sharad Kala 01-08-2005 06:56 AM

Re: Does the typename keyword make sense here?
 

"Exits Funnel" <exitsNOfunnelSPAM@yahoo.com> wrote in message
> Hello,
>
> When I try to compile the above, g++ complains thusly:

[snip]
> test1.cpp:9 syntax error before ';' token.
>
> Presumably, this code compiles under MS Visual Studio 7.1. If I remove
> the 'typename' from line nine, it's compilable under g++. Two questions
> then:
>
> 1) Is it legal. In other words, should g++ complain?


No, it isn't . g++ is correct.

> 2) If it is legal, what does it do? It's not clear to me what purpose
> typname would serve in this particular context.


Sharad




All times are GMT. The time now is 08:36 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.