Connecting Tech Pros Worldwide Help | Site Map

Does the typename keyword make sense here?

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 22nd, 2005, 11:30 PM
Exits Funnel
Guest
 
Posts: n/a
Default 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


  #2  
Old July 22nd, 2005, 11:30 PM
Sharad Kala
Guest
 
Posts: n/a
Default Re: Does the typename keyword make sense here?


"Exits Funnel" <exitsNOfunnelSPAM@yahoo.com> wrote in message[color=blue]
> Hello,
>
> When I try to compile the above, g++ complains thusly:[/color]
[snip][color=blue]
> 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?[/color]

No, it isn't . g++ is correct.
[color=blue]
> 2) If it is legal, what does it do? It's not clear to me what purpose
> typname would serve in this particular context.[/color]

Sharad


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,840 network members.