structures and classes

This is a discussion on structures and classes within the C++ Programming forums, part of the General Programming Boards category; Whats the difference? Are they not the same?...

  1. #1
    Registered User abrege's Avatar
    Join Date
    Nov 2002
    Posts
    369

    structures and classes

    Whats the difference? Are they not the same?
    I am against the teaching of evolution in schools. I am also against widespread
    literacy and the refrigeration of food.

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655
    They are the same. Well except for the minor difference that class members are by default private and struct's, public.

    Code:
    class X {
     int private_num;
     public:
     int public_num;
    };
    
    
    struct X {
     int public_num;
     private:
     int private_num;
    };
    Code:
    #include <ip.hpp>

  3. #3
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953

    Question

    Can we have member functions in structs?
    Can we make inheritance with structs?
    Can we overload operators?

    Correct me if I'm wrong... I think (no).

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Originally posted by ammar
    Can we have member functions in structs?
    Can we make inheritance with structs?
    Can we overload operators?

    Correct me if I'm wrong... I think (no).
    Yes

    Yes

    and Yes

    Structs are just like classes...excepts public by default

  5. #5
    Just a Member ammar's Avatar
    Join Date
    Jun 2002
    Posts
    953
    Mmmmmm...
    Thanks, I didn't know that...
    So there isn't a big difference.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about classes and structures.
    By RealityFusion in forum C++ Programming
    Replies: 19
    Last Post: 08-30-2005, 03:54 PM
  2. Replies: 1
    Last Post: 06-17-2005, 07:31 AM
  3. Classes and Structures.
    By jrahhali in forum C++ Programming
    Replies: 6
    Last Post: 03-28-2004, 04:03 PM
  4. Structures, Unions and Classes
    By Makoy in forum C++ Programming
    Replies: 2
    Last Post: 02-23-2004, 01:57 PM
  5. structures fooloing to look like classes
    By samsam1 in forum C++ Programming
    Replies: 4
    Last Post: 01-18-2003, 10:43 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21