1. Any program has only one main function instance, and the main function cannot be reloaded.
2. functions cannot be overloaded only based on different return types.
3. overload and scope
Code:
- String getstring ();
- Void showstring ()
- {
- String getstring = "OK ";
- String S = getstring (); // error blocked!
- Cout <s;
- }
4. Reload the following three steps:
Code:
- Void F ();
- Void F (INT );
- Void F (INT, INT );
- Void F (double, double = 3.14 );
- F (5.3 );
1. Candidate Functions
2. Determine the feasible function: F (INT) f (double, double)
3. Find the best match.
Exact matching is better than matching F (double, double) that requires type conversion)
4. Reload determination with multiple real parameters
1). Matching of each real parameter is not inferior to matching required by other feasible functions.
2). At least one real Parameter Match is better than the match provided by other feasible functions (I am crazy)
5. Matching that requires type conversion "inferior to" matching that requires type improvement
You cannot pass an integer type to an enumeration-type parameter,
However, you can pass the enumerated parameters to the shaping parameters.
6. overload and const Parameters
This parameter is affected only when it is a reference or pointer.
It cannot be overloaded based on whether the pointer is const.