Does the typename keyword make sense here?

Discussion in 'C++' started by Exits Funnel, Jan 8, 2005.

  1. Exits Funnel

    Exits Funnel Guest

    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
    Exits Funnel, Jan 8, 2005
    #1
    1. Advertising

  2. Exits Funnel

    Sharad Kala Guest

    "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
    Sharad Kala, Jan 8, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Phil Sandler

    NULLs from SQL--does this make sense?

    Phil Sandler, Aug 19, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    321
    Phil Sandler
    Aug 19, 2004
  2. Anonymous
    Replies:
    2
    Views:
    1,316
    John Carson
    Apr 13, 2004
  3. Chris Foster
    Replies:
    2
    Views:
    374
    Chris Foster
    Aug 23, 2004
  4. Jakob Bieling

    Q: typename or not typename?

    Jakob Bieling, Mar 14, 2006, in forum: C++
    Replies:
    2
    Views:
    344
    Rolf Magnus
    Mar 14, 2006
  5. Royan
    Replies:
    11
    Views:
    1,018
    Arne Vajhøj
    Oct 25, 2008
Loading...

Share This Page