Thread: structures and classes

  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,708
    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 <cmath>
    #include <complex>
    bool euler_flip(bool value)
    {
        return std::pow
        (
            std::complex<float>(std::exp(1.0)), 
            std::complex<float>(0, 1) 
            * std::complex<float>(std::atan(1.0)
            *(1 << (value + 2)))
        ).real() < 0;
    }

  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,793
    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, 05:03 PM
  4. Structures, Unions and Classes
    By Makoy in forum C++ Programming
    Replies: 2
    Last Post: 02-23-2004, 02:57 PM
  5. structures fooloing to look like classes
    By samsam1 in forum C++ Programming
    Replies: 4
    Last Post: 01-18-2003, 11:43 AM