C + + Learning Note 15: List of function prototypes for operator overloading (recommended)

Source: Internet
Author: User
Tags logical operators scalar

//General ArithmeticFriend Aoperator+(ConstA & LHS,ConstA &RHS); friend Aoperator-(ConstA & LHS,ConstA &RHS); friend Aoperator*(ConstA & LHS,ConstA &RHS); friend Aoperator/(ConstA & LHS,ConstA &RHS); friend Aoperator%(ConstA & LHS,ConstA &RHS); friend Aoperator*(ConstA & LHS,Const int& RHS);//scalar operations, if presentFriend Aoperator*(Const int& LHS,ConstA & RHS);//scalar operations, if present//Relational OperatorsFriendBOOL operator== (ConstA & LHS,ConstA &RHS); FriendBOOL operator!= (ConstA & LHS,ConstA &RHS); FriendBOOL operator< (ConstA & LHS,ConstA &RHS); FriendBOOL operator<= (ConstA & LHS,ConstA &RHS); FriendBOOL operator> (ConstA & LHS,ConstA &RHS); FriendBOOL operator>= (ConstA & LHS,ConstA &RHS);//logical OperatorsFriendBOOL operator|| (ConstA & LHS,ConstA &RHS); FriendBOOL operator&& (ConstA & LHS,ConstA &RHS);BOOLA::operator!();//positive and negative operatorsA::operator+();//take positiveA::operator-();//take negative//Increment decrement operatorA & A::operator++();//prefix incrementA::operator++(int);//suffix IncrementA & A::operator--();//prefix decrementA::operator--(int);//suffix Decrement//Dynamic Storage Management operators: Global or member functions can bevoid*operator New(std::size_t size)Throw(bad_alloc);void*operator New(std::size_t size,ConstStd::nothrow_t &)Throw();void*operator New(std::size_t size,void*Base)Throw();void*operator New[] (std::size_t size)Throw(bad_alloc);void operator Delete(void*p);void operator Delete[](void*p);//assignment operatorA &operator= (A &RHS); A&operator= (ConstA &RHS); A&operator= (A &&RHS); A&operator+= (ConstA &RHS); A&operator-= (ConstA &RHS); A&operator*= (ConstA &RHS); A&operator%= (ConstA &RHS); A&operator&= (ConstA &RHS); A&operator/= (ConstA &RHS); A&operator|= (ConstA &RHS); A&operator^= (ConstA &RHS); A&operator<<= (intN); A&operator>>= (intn);//Subscript operatorT & A::operator[] (inti);ConstT & A::operator[](intIConst;//function call operatorT A::operator()(...);//Optional Parameters//Type conversion OperatorsA::operator Char*()Const; A::operator int()Const; A::operator Double()Const;//comma operatorT2operator, (T1 t1, T2 T2);//overloading is not recommended//pointers and operator operatorsA * A::operator& ();//accessor operatorA & A::operator*();//Leading operatorsConstA & A::operator*()Const;//Leading operatorsC * A::operator();//optional operatorConstC * A::operator()Const;//optional operatorC & A::operator->* (...);//operator, pointer to class member//stream operatorFriend Ostream &operator<< (Ostream &os,ConstA &a) friend IStream&operator>> (IStream & is, A &a);

C + + Learning Note 15: List of function prototypes for operator overloading (recommended)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.