Reader and Writer are the abstract base classes of all the character stream classes. They are used to simplify the input and output programming of strings, that is, to read and write text data.

Source: Internet
Author: User

First, let's look at the following small programs:
(Input two numbers and input them in order of size. -- check whether the output value can reach the goal)
// Value transfer
# Include <iostream>
Using namespace std;
Int main ()
{
Void max (int a, int B );
Int x, y;
Cin> x> y;
Max (x, y );
Cout <x <endl <y <endl;
Return 0;
} Www.2cto.com
Void max (int a, int B)
{
Int temp;
If (a <B)
{
Temp =;
A = B;
B = temp;
}
}


// Pointer Transmission
# Include <iostream>
Using namespace std;
Int main ()
{
Void max (int * p1, int * p2 );
Int x, y;
Int * point_1, * point_2;
Cin> x> y;
Point_1 = & x;
Point_2 = & y;
Max (point_1, point_2 );
Cout <x <endl <y <endl;
Return 0;
}
Void max (int * p1, int * p2)
{
Int temp;
If (* p1 <* p2)
{
Temp = * p1;
* P1 = * p2;
* P2 = temp;
}
}

 

// Array Transfer
# Include <iostream>
Using namespace std;
Int main ()
{
Void max (int a []);
Int a [2];
Cin> a [0]> a [1];
Max ();
Cout <a [0] <endl <a [1] <endl;
Return 0;
}
Void max (int a [])
{
Int temp;
If (a [0] <a [1])
{
Temp = a [0];
A [0] = a [1];
A [1] = temp;
}
}

// Reference Transmission
# Include <iostream>
Using namespace std;
Int main ()
{
Void max (int &, int &);
Int x, y;
Cin> x> y;
Max (x, y );
Cout <x <endl <y <endl;
Return 0;
}
Void max (int & a, int & B)
{
Int temp;
If (a <B)
{
Temp =;
A = B;
B = temp;
}
}

It is not difficult to find that the first Han number cannot reach the expected goal, and the other three can. A smart person can see at a glance that the first input parameter of the Han number is the value. Other
Can be considered as an address (the pointer naturally does not have to say that the array transmits the first address, and the reference is the copy of the address ).

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.