开发者

How do I overload an operator to work with a struct?

Merged with << Operator Rewrite to cout int and double values.

I have a struct called Readings and I want to overload the < operator to work开发者_Python百科 with it. It's to compare two readings and determine which one is larger.

Here's my struct:

struct Reading {
    int hour;
    double temperature;
    Reading(int h, double t): hour(h), temperature(t) { }
};
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜