In what scenarios is it better to use a struct vs a class in C++?
When would you choose to use struct and when to use class in C++?
I use struct when I define functors and POD. Otherwise I use class.
// '()' is public by default!
struct mycompare : public std::binary_function
{
bool operator()(int first, int second)
{ return first < second; }
};
class mycompare : public std::binary_function
{
public:
bool operator()(int first, int second)
{ return first < second; }
};