Can element types be the base class?

Discussion in 'C++' started by PengYu.UT@gmail.com, Nov 17, 2007.

  1. Guest

    Hi,

    I'm wondering if there is any way to use element types as base
    classes. Or it is not possible at all?

    struct A : public int {
    };

    Thanks,
    Peng
     
    , Nov 17, 2007
    #1
    1. Advertising

  2. Kai-Uwe Bux Guest

    wrote:

    > Hi,
    >
    > I'm wondering if there is any way to use element types as base
    > classes. Or it is not possible at all?
    >
    > struct A : public int {
    > };


    It's not possible.

    You could provide a wrapper template

    template < typename T >
    class make_base {
    ...
    };

    and then do:

    struct A : public make_base<int> {
    };

    But whatever you are trying to accomplish, this probably won't help.


    On a related note: what are you trying to accomplish, anyway?


    Best

    Kai-Uwe Bux
     
    Kai-Uwe Bux, Nov 17, 2007
    #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. Replies:
    1
    Views:
    1,364
    Jonathan Mcdougall
    Dec 24, 2004
  2. Replies:
    0
    Views:
    407
  3. Alf P. Steinbach
    Replies:
    6
    Views:
    571
    John Carson
    Sep 3, 2005
  4. Hicham Mouline
    Replies:
    1
    Views:
    625
    Victor Bazarov
    Apr 20, 2009
  5. Karan Rajput
    Replies:
    2
    Views:
    155
    Abinoam Jr.
    Dec 22, 2010
Loading...

Share This Page