Structures, what's the point?

This is a discussion on Structures, what's the point? within the C++ Programming forums, part of the General Programming Boards category; I'm a noob so maybe this is a dumb question, but i'm going to ask it anyways. What is the ...

  1. #1
    Registered User
    Join Date
    Jul 2002
    Posts
    3

    Question Structures, what's the point?

    I'm a noob so maybe this is a dumb question, but i'm going to ask it anyways. What is the point of a structure? Isn't a structure just a class with all variables are public? Why not just use a class? Why are there two ways to do he exact same thing?

  2. #2
    Unregistered
    Guest

    hmm

    Class concept came with C++

    Structure concept came from C

    Maybe that's why there are two things to do the same.

    I think you can do a lot more with Classes though.. i'm not sure.
    maybe something to do with using different functions ...

  3. #3
    Still A Registered User DISGUISED's Avatar
    Join Date
    Aug 2001
    Posts
    499
    In C the struct keyword is used to define a structure that only contains data or objects of another structure (which would simply be considered a user defined data type in this case).

    C++ extended the struct keyword and gave it the same abilities as the class keyword, meaning that it could now have member functions encapsulated along with data, making it virtually the same as a class except for the default access permissions.

    I was taught to continue to use struct as I would in C (Data only) and class when member functions are required.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Testing Floating Point Return Values
    By jason_m in forum C Programming
    Replies: 5
    Last Post: 08-15-2008, 02:37 PM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. Array of pointers to point objects
    By totalfreeloader in forum C++ Programming
    Replies: 6
    Last Post: 11-27-2003, 09:26 AM
  4. Replies: 2
    Last Post: 09-10-2001, 01:00 PM

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