Use of typeof() for member data declaration (in g++)

Discussion in 'C++' started by M. Steinbach, Feb 20, 2004.

  1. M. Steinbach

    M. Steinbach Guest

    Thanks.

    ---
    class Real {
    public:
    double data;
    };

    class A {
    public:
    Real a;
    typeof( a.data ) b; // Fails
    };

    --- g++ t.C:
    t.C:10: invalid use of member 'A::a'
    t.C:10: ISO C++ forbids declaration of 'b' with no type
    Posted via Surge1


    ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
    http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
    ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
    M. Steinbach, Feb 20, 2004
    #1
    1. Advertising

  2. M. Steinbach

    tom_usenet Guest

    On 20 Feb 2004 02:28:37 -0600, M. Steinbach <>
    wrote:

    >Thanks.
    >
    >---
    >class Real {
    >public:
    > double data;
    >};
    >
    >class A {
    >public:
    > Real a;
    > typeof( a.data ) b; // Fails
    >};
    >
    >--- g++ t.C:
    >t.C:10: invalid use of member 'A::a'
    >t.C:10: ISO C++ forbids declaration of 'b' with no type
    >Posted via Surge1


    typeof is a gcc extension - you should ask on the GCC mailing lists.
    Certainly the code is illegal in standard C++ - you need:

    class A {
    public:
    Real a;
    double b; // or use a typedef in Real.
    };

    Tom

    C++ FAQ: http://www.parashift.com/c -faq-lite/
    C FAQ: http://www.eskimo.com/~scs/C-faq/top.html
    tom_usenet, Feb 20, 2004
    #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. Leon

    Using TypeOf?

    Leon, Nov 1, 2004, in forum: ASP .Net
    Replies:
    7
    Views:
    2,151
    Henri
    Nov 1, 2004
  2. M. Steinbach
    Replies:
    0
    Views:
    345
    M. Steinbach
    Feb 20, 2004
  3. fabioppp

    typeof and g++

    fabioppp, Feb 23, 2005, in forum: C++
    Replies:
    10
    Views:
    1,297
    Ben Hetland
    Feb 24, 2005
  4. Jason
    Replies:
    2
    Views:
    503
    Jonathan Mcdougall
    May 13, 2006
  5. Skybuck Flying
    Replies:
    2
    Views:
    334
    Alf P. Steinbach /Usenet
    Jun 21, 2011
Loading...

Share This Page