我想知道如何比较两个实例,方法的框架应该如何,以及如何在主实例中调用它。
在file.h中
type operator==(const& className1, const& className2);
像那样?
在file.cpp中
type operator==(const& className1, const& className2){
..................
}
像那样?
我如何在main.cpp中调用它?
每当编译器遇到表达式a == b(其中a和b都不都是原始类型)时,会自动调用operator ==。同样,返回类型通常应为bool。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句