开发平台(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拿掉就会过
但一直想不通为啥。