The fact is that structs are identical to classes except the default access.
However, what I see is that people tend to use structs when they need an aggregate data type and classes for complex data objects.
What I mean is struct is often used to represent a record in exactly the same way it is used in C.
1 2 3 4 5 6 7
|
struct address
{
std::string house;
std::string line1;
std::string line2;
std::string city;
};
|
Whereas if functions were going to be added a class would have been used instead.
The OP may have been referring to the fact that using an open struct to access the member variables can be more efficient that going through access functions.
Although, for simple access functions, any overhead can, in reality, be optimised away.
So there is often a distinct difference in the way struct and class are used even though they are physically (almost) identical.
I personally do not use structs in this way for any speed advantage because I don't believe there is any/much.
However I think it is good to use struct for aggregate data when it doesn't not make sense to hide it behind a function interface.