G****A 发帖数: 4160 | 1 ***************
class UPInt {
public:
UPInt& operator++(); %function F1
const UPInt operator++(); %function F2
...
};
******************
UPInt i;
int a;
++i; %(1)
i++; %(2)
我觉得按照语法,(2)应该call F1;(1)应该no matched function defined. 但实际
(2)call F2, (1)call F1. 请问compiler用什么rule来决定matching的?
希望我的描述还算清楚。 | t****t 发帖数: 6806 | 2 你的描述一点也不清楚, 按你这个描述肯定是编译通不过的. 除了你是在写C++而不是
matlab, 注释应该用//而不是%以外, 这两个overloading也是不能编译的. 如果你不会
抄的话, 还是copy/paste来得比较容易.
【在 G****A 的大作中提到】 : *************** : class UPInt { : public: : UPInt& operator++(); %function F1 : const UPInt operator++(); %function F2 : ... : }; : ****************** : UPInt i; : int a;
| G****A 发帖数: 4160 | 3 这个问题是朋友问我的,所以我也没有source.
但让我confuse的部分是:
如果有一个member function: UPInt& operator++();
那么对于 UPInt A; A++; ++A; which one is a valid call to the member function?
谢谢大牛耐心解释.
【在 t****t 的大作中提到】 : 你的描述一点也不清楚, 按你这个描述肯定是编译通不过的. 除了你是在写C++而不是 : matlab, 注释应该用//而不是%以外, 这两个overloading也是不能编译的. 如果你不会 : 抄的话, 还是copy/paste来得比较容易.
|
|