+ 4
Struct vs CLasses....When to use one over the other?
I am new to oops in cpp and seen structs before ...Both the data types seems kind of similar ....SO why would we need to use one over the other...?
2 Respuestas
+ 5
There are no major difference except for one...
In a class the members are private by default...(i.e they can't be used outside the class)
In a struct the members arepublic by default (i.e you can use them outside the struct too)
And use this for reference as this ? has been asked way too many times :)
https://stackoverflow.com/questions/54585/when-should-you-use-a-class-vs-a-struct-in-c
0
I would say that classes are but tricky so you can probably use the structures as they have all the members public by default and in a class all the members are private unless we declare them to be public