摘要: 1直接传递对象名用对象名传递函数参数时候,在函数调用时将建立一个新的对象,他是形参对象的拷贝例如:#includeusing namespace std;class Time{public:Time(int,int,int);void Print();void reset(Time &t);priv... 阅读全文
posted @ 2015-06-17 22:26 DannyCat 阅读(4824) 评论(2) 推荐(2) 编辑
摘要: 函数模板可以用来创建一个通用的函数,以支持多种不同形参,避免重载函数的函数体重复设计。它的最大的特点就是吧函数实用的数据类型作为参数。定义函数模板的一般形式为:template或者template1下面我们来试着用函数重载来定义不同类型的函数int:int int_add(int a,intb){i... 阅读全文
posted @ 2015-06-17 00:30 DannyCat 阅读(410) 评论(0) 推荐(0) 编辑