Why can't structs have constructors?

Discussion in 'C++' started by Tech07, Sep 6, 2009.

  1. Tech07

    Tech07 Guest

    Why can't structs have constructors?
    Tech07, Sep 6, 2009
    #1
    1. Advertising

  2. Tech07

    Ian Collins Guest

    Tech07 wrote:
    > Why can't structs have constructors?


    Because they can.

    --
    Ian Collins
    Ian Collins, Sep 6, 2009
    #2
    1. Advertising

  3. Tech07

    osmium Guest

    "Tech07" wrote:

    > Why can't structs have constructors?


    That's pretty much the same as asking "Why can't eagles fly?"
    osmium, Sep 6, 2009
    #3
  4. Tech07

    Ron Guest

    On Sep 5, 11:20 pm, "osmium" <> wrote:
    > "Tech07" wrote:
    > > Why can't structs have constructors?

    >
    > That's pretty much the same as asking "Why can't eagles fly?"


    Yep...the only difference between a struct and class is the
    default access specifier (public in struct, private in class).
    Ron, Sep 6, 2009
    #4
  5. Tech07 wrote:
    > Why can't structs have constructors?


    Let me guess: What you *really* wanted to ask was: Why can't unions
    have constructors?
    Juha Nieminen, Sep 6, 2009
    #5
  6. "Juha Nieminen" <> wrote in message
    news:dkPom.149$...
    > Tech07 wrote:
    >> Why can't structs have constructors?

    >
    > Let me guess: What you *really* wanted to ask was: Why can't unions
    > have constructors?


    it is because of the amount of actual labor involved...
    BGB / cr88192, Sep 7, 2009
    #6
  7. Tech07

    saurabh Guest

    On Sat, 05 Sep 2009 21:59:08 -0500, Tech07 wrote:

    > Why can't structs have constructors?


    They can.Looks like you studied structures from a C book,and then left
    the structure topic while starting c++.
    The only difference between Structures and Classes is ,that by default
    everything in a class is private while everything in a struct by default
    is public.
    saurabh, Sep 12, 2009
    #7
    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. Dave Rudolf
    Replies:
    12
    Views:
    8,276
    Martijn Lievaart
    Feb 6, 2004
  2. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,840
    Smokey Grindel
    Dec 2, 2006
  3. Jeremy Smith
    Replies:
    2
    Views:
    587
    Jeremy Smith
    Aug 3, 2006
  4. JohnQ
    Replies:
    51
    Views:
    1,247
    JohnQ
    Aug 4, 2007
  5. Peng Yu
    Replies:
    5
    Views:
    393
    Juha Nieminen
    Sep 19, 2008
Loading...

Share This Page