因为我已经重载了迭代器类的
operator++
template<typename T>
typename list<T>::iterator& list<T>::iterator::operator++()
{
//stuff
}
但是当我尝试这样做时
list<int>::iterator IT;
IT++;
我收到一条关于没有使用前缀形式的 postifx
++
的警告。如何专门重载 prefix/postifx 表单?
http://www.devx.com/tips/Tip/12515
class Date {
//...
public:
Date& operator++(); //prefix
Date& operator--(); //prefix
Date operator++(int unused); //postfix
Date operator--(int unused); //postfix
};
Postfix 签名中有一个 int 参数。
Class& operator++(); //Prefix
Class operator++(int); //Postfix
很多关于运算符重载的信息可以在 运算符重载,C++ 常见问题解答。
编辑:
原来的链接
(http://www.parashift.com/c++-faq-lite/operator-overloading.html)
同时解析上面链接的集合。