class or struct - that is the question

This is a discussion on class or struct - that is the question within the C++ Programming forums, part of the General Programming Boards category; I have been reading up on class and struct and their use but there is one question I don't seem ...

  1. #1
    Registered User
    Join Date
    Jan 2011
    Posts
    96

    class or struct - that is the question

    I have been reading up on class and struct and their use but there is one question I don't seem to be able to find an answer to.

    Which should I use for preference, is one or the other deprecated?

    Using class and public: appears to me to be the same thing as using struct, am I missing something here?

    You could also say using struct and private: appears to be the same thing as well, couldn't you?

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,604
    Quote Originally Posted by JayCee++ View Post
    I have been reading up on class and struct and their use but there is one question I don't seem to be able to find an answer to.

    Which should I use for preference, is one or the other deprecated?
    None of them are deprecated.

    Using class and public: appears to me to be the same thing as using struct, am I missing something here?
    That is correct.

    You could also say using struct and private: appears to be the same thing as well, couldn't you?
    That is also correct.

    Typically you can choose what you want, but the most common way to do it is to use struct simply for grouping together variables and classes when access control and member functions are necessary.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  3. #3
    Registered User
    Join Date
    Jan 2011
    Posts
    96
    Thanks Elysia for the clear and concise answers, much appreciated.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Making a (atom) class in a (struct) class makes big errors!
    By Yarin in forum Windows Programming
    Replies: 4
    Last Post: 09-11-2007, 07:18 PM
  2. class/struct question
    By darksaidin in forum C++ Programming
    Replies: 6
    Last Post: 08-03-2003, 08:13 PM
  3. Quick struct/class question
    By GrNxxDaY in forum C++ Programming
    Replies: 10
    Last Post: 07-23-2002, 06:15 PM
  4. Class/Struct Question
    By Akilla in forum C++ Programming
    Replies: 7
    Last Post: 07-19-2002, 12:29 PM
  5. struct or class
    By itld in forum C++ Programming
    Replies: 3
    Last Post: 02-04-2002, 04:21 PM

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