hi, how to overload operators in C++?
登录 | 论坛导航 -> 华新鲜事 -> 社会百科 | 本帖共有 5 楼,当前显示第 2 楼 : 从楼主开始阅读 : 本帖树形列表 : 返回上一页
作者:xscheme (等级:3 - 略知一二,发帖:939) 发表:2004-12-29 05:25:49  2楼  评分: 
depends
from your words, should do it in this way.

double operator ^(double a, double b) {
return ...;
}

this might not work, because compiler may not be able to differetiate this with its normal meaning - Bitwise Exclusive OR Operator: ^. try it by yourself with the compiler.

Remember to do cast before the actual prarameter, or it will be just Bitwise Exclusive OR Operator if it happend both operands are of int type.
没有签名档是最酷的签名档~
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表

本帖共有 5 楼,当前显示第 2 楼,本文还有 N-1 层楼,要不你试试看:点击此处阅读更多 >>



请登录后回复:帐号   密码