0

Classes verses structures?

Im new to programming, so please forgive me if this is a silly question, but what is the functional diffrence between C++ structures and classes? From what I have read, they seem very similar. In what situation is one more appropriate over the other? Thank you in advance for hand-holding a real noob.

21st Dec 2016, 10:10 AM
Jeffrey Cheeseman
3 Respostas
+ 5
Class' members are private by default. Struct's members are public by default. Besides that there are no other differences.
21st Dec 2016, 11:20 AM
Iván
Iván - avatar
+ 3
In C++ there is virtually no difference. Structures default to their members being public and classes default to private. That's the main difference that you are likey to encounter in the beginning. Normally you use structures for simplistic data structures but you could do the same thing with classes.
21st Dec 2016, 11:06 AM
James Durand
James Durand - avatar
0
I see, thank you both for that answer. I suspected that, what confused me was in the C++ book I'm reading classes and structures are covered seperatly in diffrent chapters which led me to belive that there was something more to it that I was not comprehending. I've got the basic concept now.
21st Dec 2016, 12:01 PM
Jeffrey Cheeseman