
本文共 3890 字,大约阅读时间需要 12 分钟。
C++���������������������
���������������������������
������������������C++������������������������������������������������������������������������������������������������������������������������������������������������������ tblabez���������������������������C++������������������������������������������������������������������������������������������������������������������������
+
���������������������������������������������������������������������������<
������������������������������������������������������������������������
������������������������������������������������������������������������������������������������������������
���������������������������������������������������������������������������������������������������������������
������������������������������������
���C++���������������������������������������������������
���������������������������������������������������������������������������������������������������������
������������������������������������������������������������������������������������������������������������+
������������������������������������������������������
��������������������������������������������� a + b
��������������������� a.operator+(b)
���������������������������������������������������������������������������������
���������������������������������������������������������������������
- ������������������������������
.
,*
,::
,sizeof
, ���?:
werent't��������������� - ������������������������������������������������������������������������������������
==
��������������������������������� - ������������������������������������������������������������������������������������������
*
���������������������������+
��������������������������������������� - ������������������������������������������������������������������������������������������������������������������������������������
������������������������������������
��������������������������������������������������������������������������������������������� Integer
���������
class Integer {public: Integer(int value) : m_value(value) {} const Integer operator+(const Integer other) const; const Integer operator-(const Integer other) const; const Integer operator*(const Integer other) const; const Integer operator/(const Integer other) const; const Integer operator%(const Integer other) const; const Integer& operator=(const Integer& other); ~Integer(); int intValue() const { return m_value; }private: int m_value;};
���������
operator+
���������������Integer
������������������������operator=
���������������������������������������������������������������������������
������������������������������������������
��������������������� Integer
������ num1
��� num2
���������������������������������������������
Integer num3 = num1 + num2; // ������ num1.operator+(num2)
��������������������������� +
���������������������������������������������������������
���������������������������������������������
������������������������������������������������������
������������������������������������������������������������������������������������������������������������������
������������������������������������������������������������������������������������������������ x = x + y
������������������������������������������������������������
��������������������������������������� static_cast
������ const/ilnk
������������������������������
������������
������������������C++������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������ API���
���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
