重载==运算符以使用字符串比较来比较两个char [] [英] Overloading the == operator to compare two char[] using a string comparison
本文介绍了重载==运算符以使用字符串比较来比较两个char []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以重载 ==
运算符,以便使用字符串比较比较两个 char []
/ p>
Can the ==
operator be overloaded so as to compare two char[]
using a string comparison?
推荐答案
否;操作符重载的至少一个参数必须是类或枚举类型。
No; at least one parameter of an operator overload must be of class or enumeration type.
char []
和 char *
是数组和指针类型,不是类或枚举类型。
char[]
and char*
are array and pointer types, which are not class or enumeration types.
这篇关于重载==运算符以使用字符串比较来比较两个char []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文