Algorithm to add or subtract days from a date?

后端 未结 10 1235
野的像风
野的像风 2020-12-01 14:10

I\'m trying to write a Date class in an attempt to learn C++.

I\'m trying to find an algorithm to add or subtract days to a date, where Day starts from 1 and Month s

10条回答
  •  清歌不尽
    2020-12-01 14:45

    I'm assuming this is for some kind of an exercise, otherwise you would use a time class that's already provided to you.

    You could store your time as the number of milliseconds since a certain date. And then you can add the appropriate value and convert from that to the date upon calling the accessors of your class.

提交回复
热议问题