Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > Does the typename keyword make sense here?

Reply
Thread Tools

Does the typename keyword make sense here?

 
 
Exits Funnel
Guest
Posts: n/a
 
      01-08-2005
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

 
Reply With Quote
 
 
 
 
Sharad Kala
Guest
Posts: n/a
 
      01-08-2005

"Exits Funnel" <> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is there any sense in using final keyword in catch block? Royan Java 11 10-25-2008 10:02 PM
Q: typename or not typename? Jakob Bieling C++ 2 03-14-2006 03:44 PM
the typename keyword - inheriting types from templated classes Chris Foster C++ 2 08-23-2004 11:09 AM
NULLs from SQL--does this make sense? Phil Sandler ASP .Net 1 08-19-2004 09:50 PM
Why do I need the typename keyword? Anonymous C++ 2 04-13-2004 10:04 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57