operator=

operator>>

operator<<

BOOL operator==(CCharFormat& cf);

    class Tmyclas
    {
    private:
        int a, b;

    public:
        Tmyclas(int a, int b) {;
        }

        Tmyclas() {;
        }

        Tmyclas operator +(Tmyclas a) {Tmyclas t;            return t;        }

        __fastcall operator AnsiString() const {return "im AnsiString";
        };

        __fastcall operator String() const {return "im String";        };
    };

    int r, s, a, b;
    Tmyclas x(r, s), y(a, b), c;

    c = x + y;
    this->Edit1->Text = c;

 类相加

c = x + y;
操作符定义
Tmyclas operator +(Tmyclas a) {Tmyclas t;            return t;        }

类转换操作符定义
__fastcall operator String() const {return "im String";        };
 可以参考Variant类型操作符的定义
// Assignments
    Variant& __fastcall operator =(const Variant& rhs);

    Variant& __fastcall operator =(const bool src);

    Variant& __fastcall operator =(const char src);
    Variant& __fastcall operator =(const signed char src);
    Variant& __fastcall operator =(const unsigned char src);

    Variant& __fastcall operator =(const short src);
    Variant& __fastcall operator =(const unsigned short src);

    Variant& __fastcall operator =(const int src);
    Variant& __fastcall operator =(const unsigned int src);

    Variant& __fastcall operator =(const long src);
    Variant& __fastcall operator =(const unsigned long src);

    Variant& __fastcall operator =(const float src);
    Variant& __fastcall operator =(const double src);
    Variant& __fastcall operator =(const __int64 src);
    Variant& __fastcall operator =(const unsigned __int64 src);

 

 
/ Exotic operators
    Variant& __fastcall operator +=(const Variant& rhs);
    Variant& __fastcall operator -=(const Variant& rhs);
    Variant& __fastcall operator *=(const Variant& rhs);
    Variant& __fastcall operator /=(const Variant& rhs);
    Variant& __fastcall operator %=(const Variant& rhs);
    Variant& __fastcall operator &=(const Variant& rhs);
    Variant& __fastcall operator |=(const Variant& rhs);
    Variant& __fastcall operator ^=(const Variant& rhs);
    Variant& __fastcall operator <<=(const Variant& rhs);
    Variant& __fastcall operator >>=(const Variant& rhs);

    // comparisons (Variant on right)
    bool __fastcall operator ==(const Variant& rhs) const;
    bool __fastcall operator !=(const Variant& rhs) const;
    bool __fastcall operator < (const Variant& rhs) const;
    bool __fastcall operator > (const Variant& rhs) const;
    bool __fastcall operator <=(const Variant& rhs) const;
    bool __fastcall operator >=(const Variant& rhs) const;

 

posted on 2015-12-18 09:42  lypzxy  阅读(388)  评论(0编辑  收藏  举报