Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6682463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T04:42:33+00:00 2026-05-26T04:42:33+00:00

Possible Duplicate: What are the differences between struct and class in C++ I’ve done

  • 0

Possible Duplicate:
What are the differences between struct and class in C++

I’ve done my homework and had diverse answers on Google.
Some say structs do not have inheritance, some say structs do not have access specifiers, while others say they have both.
Could someone clarify then, the differences between a struct and a class in C and C++, and also the difference between a struct in C & C++.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T04:42:34+00:00Added an answer on May 26, 2026 at 4:42 am

    In C++, the only difference between a struct and a class is that struct members are public by default, and class members are private by default.

    However, as a matter of style, it’s best to use the struct keyword for something that could reasonably be a struct in C (more or less POD types), and the class keyword if it uses C++-specific features such as inheritance and member functions.

    C does not have classes.

    C structs cannot use C++-specific features.

    EDIT:

    The C++ FAQ Lite, question 7.9, has this to say:

    The members and base classes of a struct are public by default,
    while in class, they default to private. Note: you should make
    your base classes explicitly public, private, or protected,
    rather than relying on the defaults.

    struct and class are otherwise functionally equivalent.

    OK, enough of that squeaky clean techno talk. Emotionally, most
    developers make a strong distinction between a class and a struct.
    A struct simply feels like an open pile of bits with very little
    in the way of encapsulation or functionality. A class feels like a
    living and responsible member of society with intelligent services, a
    strong encapsulation barrier, and a well defined interface. Since
    that’s the connotation most people already have, you should probably
    use the struct keyword if you have a class that has very few methods
    and has public data (such things do exist in well designed
    systems!), but otherwise you should probably use the class keyword.

    And quoting Stroustrup’s “The C++ Programming Language”, 4th edition, section 16.2.4:

    These two definitions of S are interchangeable, though it is
    usually wise to stick to one style. Which style you use depends on
    circumstances and taste. I tend to use struct for classes that I
    think of as “just simple data structures.” If I think of a class as “a
    proper type with an invariant,” I use class. Constructors and
    access functions can be quite useful even for *struct*s, but as a
    shorthand rather than guarantors of invariants.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: What are the differences between struct and class in C++ http://www.cplusplus.com/reference/std/typeinfo/type_info/ I
Possible Duplicate: What are the differences between struct and class in C++ If the
Possible Duplicate: C/C++ Struct vs Class I know the technical differences between a struct
Possible Duplicate: What are the differences between struct and class in C++ I used
Possible Duplicate: What are the differences between struct and class in C++ In C++
Possible Duplicate: Real differences between “java -server” and “java -client”? I've seen the argument
Possible Duplicate: What are the specific differences between .msi and setup.exe file? I am
Possible Duplicate: In WPF, what are the differences between the x:Name and Name attributes?
Possible Duplicate: What is the difference between "typename" and "class" template parameters? When defining
Possible Duplicate: What are major differences between C# and Java? I believe it was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.