로딩
요청 처리 중입니다...

[cpp] struct (with equatable, comparable)

 [cpp] struct (with equatable, comparable)

#include struct DateInfo { int year; int month; int day; bool operator<(const DateInfo& rhs) const { if (year != rhs.year) { return year < rhs.year; } else { if (month !

= rhs.month) { return month < rhs.month; } else { return day < rhs.day; } } } bool operator==(const DateInfo& rhs) const { return year == rhs.year && month == rhs.month && day == rhs.day; } }; 이렇게 작성하면 Swift 의 Equatable 과 comparable을 채택한 것 과 같다. import Foundation struct DateInfo: Comparable, Equatable { var year: Int v...