C Operator priority, operator priority
Priority
Operator
Name or meaning
Usage
Integration direction
Description
1
[]
Array subscript
Array name [constant expression]
Left to right
()
One, operator overloadingThe operands of predefined operators in C + + can only be basic data types, and in fact, for many user-defined types, similar operations are required. What would happen if these existing operators in C + + were directly
We know that operator overloading in C + + has two forms: the ① overload is a member function of the class (see C + + operator overloading (member function mode)), and ② overloads the friend function for the class.When you overload a friend function,
DescriptionDefines a rectangular class that includes the lower-left and upper-right coordinates, defined member functions that include the necessary constructors, functions for input coordinates, implementation of the rectangle addition, and
Refer to Microsoft Help1? a null-value conditional operator that tests for the presence of NULL before performing a member access ( ?. ) or index ( ?[ ) operation.1 // ? null-value condition operator 2 string NULL ; 3 Console.WriteLine (str?. length)
One, operator overloading:Operator overloading is a polymorphic type that extends the functionality of operators so that operators are not only used for built-in data types.Ii. rules for operator overloading: 1.c++ does not allow users to define
Priority Level
operator
Description
Example
Binding Nature
1
()[]-.::++--
The parentheses operator that adjusts the precedenceArray Subscript access operatorTo access a member's operator by pointing to the
Blog Address : http://blog.csdn.net/shulianghan/article/details/416246131. Arithmetic Operatorsarithmetic operators : Plus (+), minus (-), multiply (*), except (/), modulo (%), self-increment (+ +);-- Other operations : if the square open operation
All unary and binary operators have pre-defined implementations, that are automatically available in any expressions. In addition to this pre-defined implementations, user defined implementations can also be introduced in C #.Mechanisms of giving a
C # operator and, Or, XOR and shift operations
1. Analyze the exclusive or operation (^)
Binary ^ operators are predefined for integer and bool types. For an integer, ^ returns the bitwise XOR of the calculated operand ". For the bool operand, the
Operator overload
Meaning:
You can also directly use the operators provided by C ++ for abstract data types.
Give multiple meanings to existing operators
Make the same operator generate different behaviors for different data types
Purpose:
--
C ++ operator reload notes
Today I read the operator overload in c ++ and record it for later viewing:
# Include
Using namespace std; class F {int n; int d; void reduce () {int mcd = maxcd (n d =-this-> d; this-> n =-this-> n;} reduce ();
[C ++] Operator Overloading in the String class, string Operator
Modular Design:
Header file:
# Ifndef operator_operator_h # define operator_operator_h # include # include using namespace std; class MyString {public: // three overloaded
The following is a detailed summary of the description and function of various operational symbols in C #first, []square brackets ([]) are used for arrays, indexers, and properties, and also for pointers.1, the array type is a type followed by
Operator 1, arithmetic operatorsNote: ①++ and – can appear either to the left of the operand or to the right, but the result is a different drop②/refers to the addition of the integer part, the decimal point is omitted;2, assignment operatorNote: ①
Private icacheclient _cache;public icacheclient cache{ get { ?? (_cache = hostcontext.resolve ());} } There is one in this code?? operator, I have always thought that this operator is (?:) A variant of the conditional operator that
Keyword operatorOperator overloading essence is the invocation of a functionreturn type operator operator (argument list){code: ;}Unary operator overloadingsuch as the minusreturn type operator-(){Member variable =-member variable;return *this;}The
#include "stdafx.h"Class a{Publicint test;A (int j=0) {Test=j;}Operator overloading basic Format return value + keyword +opereator+ reload symbol + () {}Essentially, this is exactly like a function, except that the function name is changed to
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.