struct vs. class usage

Discussion in 'C++' started by subramanian, Dec 29, 2006.

  1. subramanian

    subramanian Guest

    What is the difference between a struct and a class ?

    When should a struct be used and when should a class be used ?
    subramanian, Dec 29, 2006
    #1
    1. Advertising

  2. subramanian

    Salt_Peter Guest

    subramanian wrote:
    > What is the difference between a struct and a class ?
    >
    > When should a struct be used and when should a class be used ?


    The only difference is the name itself and the default access.
    Some will suggest using struct for PODs (Palin Old Data).
    Otherwise they are exactly the same.
    Salt_Peter, Dec 29, 2006
    #2
    1. Advertising

  3. subramanian

    kwikius Guest

    subramanian wrote:
    > What is the difference between a struct and a class ?
    >
    > When should a struct be used and when should a class be used ?


    FWIW this and many other things are covered in the associated faq:

    http://www.parashift.com/c -faq-lite/

    regards
    Andy Little
    kwikius, Dec 29, 2006
    #3
  4. subramanian

    Spoon Guest

    Spoon, Dec 29, 2006
    #4
  5. subramanian wrote:
    > What is the difference between a struct and a class ?
    >
    > When should a struct be used and when should a class be used ?


    as already few friends told access difference in struct and class but i
    suggests you to write code related to struct in .c file and related to
    class in .cpp file, after that one by one apply all concept of Object
    Oriented Concept on both files then you will find crystal difference
    between struct and class.

    i hope it will helps you.

    regards,

    -aims
    Mohammad Omer Nasir, Dec 29, 2006
    #5
  6. Bingo asim!
    Rest all differences mentioned are meant between "c++" struct and
    class. But mind you, c and c++ structures are a lot different (see to
    it like struct in c is given all OO power of class in c++)

    Sandip Shahane

    Mohammad Omer Nasir wrote:
    > subramanian wrote:
    > > What is the difference between a struct and a class ?
    > >
    > > When should a struct be used and when should a class be used ?

    >
    > as already few friends told access difference in struct and class but i
    > suggests you to write code related to struct in .c file and related to
    > class in .cpp file, after that one by one apply all concept of Object
    > Oriented Concept on both files then you will find crystal difference
    > between struct and class.
    >
    > i hope it will helps you.
    >
    > regards,
    >
    > -aims
    Sandip Shahane, Dec 29, 2006
    #6
  7. subramanian

    Salt_Peter Guest

    Sandip Shahane wrote:
    > Bingo asim!
    > Rest all differences mentioned are meant between "c++" struct and
    > class. But mind you, c and c++ structures are a lot different (see to
    > it like struct in c is given all OO power of class in c++)
    >
    > Sandip Shahane


    Please don't top Post.

    >
    > Mohammad Omer Nasir wrote:
    > > subramanian wrote:
    > > > What is the difference between a struct and a class ?
    > > >
    > > > When should a struct be used and when should a class be used ?

    > >
    > > as already few friends told access difference in struct and class but i
    > > suggests you to write code related to struct in .c file and related to
    > > class in .cpp file, after that one by one apply all concept of Object
    > > Oriented Concept on both files then you will find crystal difference
    > > between struct and class.
    > >
    > > i hope it will helps you.
    > >
    > > regards,
    > >
    > > -aims
    Salt_Peter, Dec 29, 2006
    #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. metfan
    Replies:
    2
    Views:
    4,847
    Robert Olofsson
    Oct 21, 2003
  2. E11
    Replies:
    1
    Views:
    4,743
    Thomas Weidenfeller
    Oct 12, 2005
  3. Chris Fogelklou
    Replies:
    36
    Views:
    1,373
    Chris Fogelklou
    Apr 20, 2004
  4. Colin J. Williams

    Webchecker Usage - a problem with local usage

    Colin J. Williams, Feb 25, 2004, in forum: Python
    Replies:
    1
    Views:
    536
    Colin J. Williams
    Feb 26, 2004
  5. Replies:
    2
    Views:
    736
    David Harmon
    Sep 20, 2006
Loading...

Share This Page