/// test.h
typedef struct stImage
{
stImage() : width(0), height(0) {}
stImage(int w, int h) : width(w), height(h) {}
int width;
int height;
}stImage;
struct AddImage
{
stImage operator()(stImage total, const stImage& p) const
{
total.width += p.width;
total.height += p.height;
return total;
}
};
/// test.cpp
vector<stImage> vecImg;
stImage sum = std::accumulate(vecImg.begin(), vecImg.end(), stImage(), AddImage());
01-28
436
