inner classes allowed consrtuctors?

Discussion in 'C++' started by gara.matt@gmail.com, Jul 18, 2007.

  1. Guest

    Hi,

    Are nested/inner class allowed to have constructors?

    When I try to compile something like

    class A{

    public:

    class B{
    public:
    B(int a)
    { b =a;}

    int b;
    }

    };


    I get the error:

    error: expected ',' or '...' before numeric constant on line "B(int
    a)"
    , Jul 18, 2007
    #1
    1. Advertising

  2. Sumit Rajan Guest

    wrote:
    > Hi,
    >
    > Are nested/inner class allowed to have constructors?
    >
    > When I try to compile something like
    >
    > class A{
    >
    > public:
    >
    > class B{
    > public:
    > B(int a)
    > { b =a;}
    >
    > int b;
    > }


    Insert a ";" here.

    >
    > };
    >
    >
    > I get the error:
    >
    > error: expected ',' or '...' before numeric constant on line "B(int
    > a)"
    >


    Hope that helps.

    Regards,
    Sumit.

    --
    Sumit Rajan <>
    Sumit Rajan, Jul 18, 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. lonelyplanet999
    Replies:
    1
    Views:
    2,198
    VisionSet
    Nov 13, 2003
  2. Razvan
    Replies:
    5
    Views:
    11,279
    Dale King
    Jul 27, 2004
  3. Christian Bongiorno
    Replies:
    5
    Views:
    531
    Chris Uppal
    Aug 30, 2004
  4. Carlo v. Dango
    Replies:
    14
    Views:
    1,013
    Alex Martelli
    Oct 19, 2003
  5. Pyenos
    Replies:
    2
    Views:
    378
    Pyenos
    Dec 27, 2006
Loading...

Share This Page