a class that does not have a default constructor

Discussion in 'C++' started by asdf, Oct 2, 2006.

  1. asdf

    asdf Guest

    what does it mean? Could you please show me an example ?

    For a class without a default constructor,how to initialize ?
     
    asdf, Oct 2, 2006
    #1
    1. Advertising

  2. asdf

    benben Guest

    asdf wrote:
    > what does it mean? Could you please show me an example ?
    >
    > For a class without a default constructor,how to initialize ?
    >



    class C
    {
    public: C(int i){}
    };

    C c1; // error
    C c2(1234); // Ok

    Ben
     
    benben, Oct 2, 2006
    #2
    1. Advertising

  3. asdf

    asdf Guest

    thanks.
    benben wrote:
    > asdf wrote:
    > > what does it mean? Could you please show me an example ?
    > >
    > > For a class without a default constructor,how to initialize ?
    > >

    >
    >
    > class C
    > {
    > public: C(int i){}
    > };
    >
    > C c1; // error
    > C c2(1234); // Ok
    >
    > Ben
     
    asdf, Oct 2, 2006
    #3
    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. mrstephengross
    Replies:
    5
    Views:
    598
    Larry I Smith
    May 18, 2005
  2. Replies:
    9
    Views:
    965
    Alf P. Steinbach
    Mar 6, 2006
  3. ali
    Replies:
    4
    Views:
    579
    David Harmon
    Mar 5, 2007
  4. www
    Replies:
    2
    Views:
    320
  5. Generic Usenet Account
    Replies:
    10
    Views:
    2,245
Loading...

Share This Page