In C #, the syntax for reloading the auto-increment and auto-Subtract operators is nothing special, as shown below:
Public static sometype operator ++ (sometype some){// Specific implementation}
For auto-increment and auto-subtraction operators in C
Next, let's take a look at the example of the c ++ overload post-auto-addition operator. If you need to learn the C ++ auto-addition operator, you can refer to it.
The Code is as follows:
Copy code
# Include Using namespace
Auto load of overload and class. PHP 4 already has an overloaded syntax to map external object models, just like Java and COM. PHP5 brings powerful object-oriented overloading, allowing programmers to establish custom behaviors. PHP4 already has an
Prefix and suffix of the auto-increment and auto-increment operators, and suffix of the operator prefix.
There is such a question in the exam:
12
inta = 4;(++a) += i;
Evaluate the value of a. The correct answer is 10.
If you think
I. Why use Operator Overloading?For all operators of the system, generally, only the basic data types and classes provided in the standard library are supported. for user-defined classes, if you want to support basic operations, such as comparing
A simple example of C ++ overload Operators
We can redefine or reload most of the built-in operators in C ++. In this way, you can use custom operators.
The overloaded operator is a function with a special name. The function name is composed of the
Method overloading (overload) and overwrite (override)Sometimes, the same function of a class is implemented in many ways, depending on the parameters given by the caller. For example, our most commonly used System.out.println () can print out data
Clause 5: Be careful with user-defined conversion functions
C ++ allows the compiler to implicitly convert two data types. (Implicit conversion). First, C ++ inherits the type conversion policy of C language.
In addition, C ++ has two types of
When reading C ++ primerCode:
Istream_iterator Int> In_iter (CIN );//Read ints From CINIstream_iterator Int> EOF;//Istream "end" iterator//Read until end of file, storing what read in VECWhile(In_iter! =EOF ){//Increament advances the stream 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.