+ 2
How do you know when to use a class or struct in C++?
2 Antworten
+ 3
I don't see much difference except default access specifier.... I personally use structure when I just want to store data and reuse it with No requiremnt for methods (even though struct can also have methods).... With this, we are not doing encapsulation properly, but in this case, sole purpose of data storage is fulfilled...
consider below case :
You are going to have multiple points with x,y and z coordinates.. for this, you can either use multimap , three vectors of double type each one for x, y and z... I prefer to declare structure with three members and pass this structure as vector to store all details for all points