開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
GCC
問題(Question):
In function 'const int operator-(const myDate&, const myDate&)':
101-21 [Error] passing 'const myDate' as 'this' argument of
'int myDate::dayOfYear()' discards qualifiers [-fpermissive]
102-21 [Error] passing 'const myDate' as 'this' argument of
'int myDate::dayOfYear()' discards qualifiers [-fpermissive]
程式碼(Code):(請善用置底文網頁, 記得排版)
http://ideone.com/BNMlxw
補充說明(Supplement):
我用operator overloding 要算出兩個日期相差幾天
目前的問題就是不知道哪裡出錯一直編譯不過
我有找到如果把friend const int operator
-(const myDate& day1 , const myDate& day2)
其中括號裡的兩個const拿掉就會過
但一直想不通為啥。