Jump to content
  • Advertisement
Sign in to follow this  
retroworld

C++ struct and class

This topic is 2907 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have just realised that C++ struct and class do exactly the same thing. they can be public or private or protected. they both can have a constructure and a destructure and you can have functions as well as variables in them.

The only difference I found was that by default, struct is public accessed and class is private.

are there any difference between these.?

Share this post


Link to post
Share on other sites
Advertisement
Its a pedantic point, but structs use public inheritance by default and classes use private inheritance.

Be aware than some coding conventions use structs exclusively for simple, or even POD types, whereas classes are typically used for more complex types. This is far from universal though.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!