操作符重载要点.ppt

操作符重载要点

int Birthday::sheet[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int main(){ Birthday lxl(1940,11,27,Bruce Lee); Birthday cl(1954,4,7,Jackie Chan); int days = 0; coutlxl.GetName()s birthday is: lxl.GetYear() . lxl.GetMonth() . lxl.GetDay()endl; coutcl.GetName()s birthday is: cl.GetYear(). cl.GetMonth() . cl.GetDay()endl; if(lxl cl){ days = lxl - cl; cout cl.GetName() is older.(abs(days) days)endl; } else if(lxl==cl) cout They are the same age.endl; else{ days = lxl - cl; cout lxl.GetName() is older.(abs(days) days)endl; } return 0; } 8.3.4 重载函数调用符() 重载格式 类型 类 :: opera

文档评论(0)

1亿VIP精品文档

相关文档