Description:
Haoran is a “huge god” who loves C++ so much.One day he wants to implement a template function cmp which compares any type of two elements.Now he passes the mission to you all and hopes you can implement it and makes it suitable to compare any two int, double, float, char*, string and any two same type of pointers.If the first parameter is equal to the second one, then return true, elsewise, false.
You can be careful that:
(1)When comparing two int, double, float, char*, string , you should compare their values.(比较实际的值).
(2)When comparing two pointers, you should compare the values they point to.
(3)the cmp function should always return a boolean value.
Here is my answer:
//cmp.h:
#include "string"
#include "cstring"
template&

这是一道关于C++函数模板的练习题,要求实现一个cmp模板函数,能够比较不同类型的数据,包括int, double, float, char*, string以及相同类型的指针。当两个参数相等时返回true,否则返回false。比较时要注意对基本类型比较值,对指针比较其所指的值,并确保函数始终返回布尔值。"
111563632,8407145,数据库系统概论复习笔记,"['数据库', '数据模型', '关系数据库', 'SQL语句', '数据库设计']
最低0.47元/天 解锁文章
2179

被折叠的 条评论
为什么被折叠?



